Problem with GitHub workflow that automatically adds a "no changelog" label
Open
Nobody has claimed this yet.
GitHub Actions
- Dominant language
- Python
- Stars
- 711
- Forks
- 375
- Avg merge
- 3h 2m
- Merged PRs (30d)
- 8
Description
The following error has been happening for pull requests that match the patterns below.
To reproduce this error, create a pull request to main that has "Minor" in the title.
Run actions/github-script@v7
with:
github-token: ***
script: // Regular expression to match the PR title pattern "Bump * from * to *"
const bumpPattern = /^Bump .* from .* to .*/;
// Fetch the PR
const { data: pullRequest } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
if (
pullRequest.title.includes('autoupdate') ||
pullRequest.title.includes('Minor') ||
pullRequest.title.includes('Fix typo') ||
pullRequest.title.includes('Update changelog entries') ||
pullRequest.title.includes('Update changelog prior to') ||
pullRequest.title.includes('Update pinned requirements') ||
pullRequest.title.includes('Update release checklist') ||
bumpPattern.test(pullRequest.title)
) {
// If yes, then apply the label "no changelog entry needed"
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['no changelog entry needed'],
});
}
debug: false
user-agent: actions/github-script
result-encoding: json
retries: 0
retry-exempt-status-codes: 400,401,403,404,422
env:
CHANGELOG_INSTRUCTIONS: ⚠️ Please add a changelog entry at `changelog/NUMBER.TYPE.rst`, where `NUMBER` is the pull request number and `TYPE` is one of `feature`, `trivial`, `doc`, `internal`, `bugfix`, `breaking`, or `removal`.
Minor change such as typo fixes and hyperlink updates do not need a changelog entry.
For details, see: https://docs.plasmapy.org/en/latest/contributing/changelog_guide.html#adding-a-changelog-entry
RequestError [HttpError]: Resource not accessible by integration
Error: Unhandled error: HttpError: Resource not accessible by integration
at /home/runner/work/_actions/actions/github-script/v7/dist/index.js:9537:21
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35424:16), <anonymous>:24:3)
at async main (/home/runner/work/_actions/actions/github-script/v7/dist/index.js:35522:20) {
status: 403,
response: {
url: 'https://api.github.com/repos/PlasmaPy/PlasmaPy/issues/2759/labels',
status: 403,
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',
'content-encoding': 'gzip',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Sat, 13 Jul 2024 01:14:54 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'github.com',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
'transfer-encoding': 'chunked',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-accepted-github-permissions': 'issues=write; pull_requests=write',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-api-version-selected': '2022-11-28',
'x-github-media-type': 'github.v3; format=json',
'x-github-request-id': '9441:13E02E:98A7D6:11065FC:6691D50E',
'x-ratelimit-limit': '5000',
'x-ratelimit-remaining': '4940',
'x-ratelimit-reset': '1720834470',
'x-ratelimit-resource': 'core',
'x-ratelimit-used': '60',
'x-xss-protection': '0'
},
data: {
message: 'Resource not accessible by integration',
documentation_url: 'https://docs.github.com/rest/issues/labels#add-labels-to-an-issue',
status: '403'
}
},
request: {
method: 'POST',
url: 'https://api.github.com/repos/PlasmaPy/PlasmaPy/issues/2759/labels',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'actions/github-script octokit-core.js/5.0.1 Node.js/20.13.1 (linux; x64)',
authorization: 'token [REDACTED]',
'content-type': 'application/json; charset=utf-8'
},
body: '{"labels":["no changelog entry needed"]}',
request: {
agent: [Agent],
fetch: [Function: proxyFetch],
hook: [Function: bound bound register]
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the GitHub workflow containing actions/github-script@v7 and reproduce the failure using a pull request titled "Minor". Trace the addLabels request and its 403 response, then verify that matching pull requests receive the "no changelog entry needed" label without an unhandled error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, javascript
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100