git-pr-release-action
git-pr-release-action copied to clipboard
Ensure no labels will try to be created if none are passed from the yaml
Currently, if no labels are passed from the workflow's yaml file, this action will attempt to create a label by mistake.
This line:
const labels = (labelsCsv || '').split(',').map(l => l.trim());
Will make labels
be [""]
, and once this is passed to gitPrRelease
, a label creation will be attempted given that the length of the array is not 0. This error causes the action to log an error like this when no labels present in the yaml file.
Example action config int he yaml:
# Note how there is no 'labels' entry under 'with'
steps:
- name: checkout
uses: actions/checkout@v1
- name: create-release-pr
uses: grassedge/[email protected]
with:
base: main
head: release
template: .github/workflows/a-template.md
assign: true
token: ${{ secrets.GITHUB_TOKEN }}
Error thrown:
Run grassedge/[email protected]
with:
base: main
head: release
template: .github/workflows/a-template.md
assign: true
token: ***
RequestError [HttpError]: Validation Failed: {"value":"","resource":"Label","field":"name","code":"invalid"}
at /home/runner/work/_actions/grassedge/git-pr-release-action/v1.0/dist/index.js:13297:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async module.exports.531.module.exports (/home/runner/work/_actions/grassedge/git-pr-release-action/v1.0/dist/index.js:12512:5)
at async main (/home/runner/work/_actions/grassedge/git-pr-release-action/v1.0/dist/index.js:12442:21) {
status: 422,
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',
connection: 'close',
'content-length': '197',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Mon, 30 May 2022 07:39:20 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': '0445:38F0:147A00B:263A19E:629474A8',
'x-ratelimit-limit': '1000',
'x-ratelimit-remaining': '996',
'x-ratelimit-reset': '1653899957',
'x-ratelimit-resource': 'core',
'x-ratelimit-used': '4',
'x-xss-protection': '0'
},
request: {
method: 'POST',
url: 'https://api.github.com/repos/myOrgn/my-repo/issues/250/labels',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'octokit.js/16.36.0 Node.js/12.22.7 (Linux 5.13; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: '{"labels":[""]}',
request: { hook: [Function: bound bound register], validate: [Object] }
},
errors: [ { value: '', resource: 'Label', field: 'name', code: 'invalid' } ],
documentation_url: 'https://docs.github.com/rest/reference/issues#add-labels-to-an-issue'
}