Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure no labels will try to be created if none are passed from the yaml #15

Open
wants to merge 43 commits into
base: master
Choose a base branch
from

Conversation

markelarizaga
Copy link

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'
}

Markel Arizaga and others added 30 commits May 30, 2022 10:20
…e logging of the action

This PR also incorporates the code of 2 depenndecies of the action to the same project.

SWP-557755 Update dependency to get is from the splash project

SWP-557755 Update dependency to get is from the splash project

SWP-557755 Add more info of the returned PR object to be logged into the console

SWP-557755 Try to throw more logs about the returned PR object

1.0.2

SWP-557755 PUtting all the code in a single project to ease modification

SWP-557755 Fix require path of detect module

SWP-557755 Add import of core to use it later in the module
SWP-557755 Delay calls to GH search api to avoid hitting limits
SWP-87550 upgrade version of node to the last allowed version
SWP-95498 Add retrying logic via Octokit Throttling plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants