feat: use pulls API when issue processing is fully disabled#1334
Open
roramirez wants to merge 1 commit intoactions:mainfrom
Open
feat: use pulls API when issue processing is fully disabled#1334roramirez wants to merge 1 commit intoactions:mainfrom
roramirez wants to merge 1 commit intoactions:mainfrom
Conversation
When both days-before-issue-stale and days-before-issue-close are set
to -1, getIssues now calls pulls.list instead of issues.listForRepo.
This avoids the need for any issues permission in the workflow, since
the GitHub issues API is never called.
- Sort field 'comments' is mapped to 'created' for the pulls API
(which does not support comments sorting)
- Items returned via pulls.list are mapped with pull_request: {}
so they are correctly identified as pull requests downstream
- Adds tests covering all branching conditions and the PR mapping
- Documents the permission optimization in README
14ecec0 to
60f05ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When both
days-before-issue-staleanddays-before-issue-closeare set to-1,getIssuesnow callspulls.listinstead ofissues.listForRepo. This avoids the need for anyissuespermission in the workflow, since the GitHub issues API is never called.Before this change, even with issue processing fully disabled via
-1, the action would still callissues.listForRepoon every run — which requiresissues: readorissues: write. This caused failures in setups where the GitHub App or token does not have issues permission (e.g. repositories with issues disabled, or App tokens scoped only to pull requests).Changes:
src/classes/issues-processor.ts:getIssueschecks if issues are fully disabled (daysBeforeIssueStale < 0 && daysBeforeIssueClose < 0) and usespulls.listin that casecommentsis mapped tocreatedfor the pulls API, which does not support comments sortingpulls.listare mapped withpull_request: {}so they are correctly identified as pull requests downstream__tests__/get-issues-api-selection.spec.ts: 8 tests covering all branching conditions (both -1, only one -1, NaN fallback, PR mapping, sort field mapping)README.md: documents the permission optimization in the "Recommended permissions" section and in thedays-before-issue-stale/days-before-issue-closeoption descriptionsRelated issue
Fixes #1307
Check list