docs(readme): add missing permission for delete-branch option in readme #796
+3
−2
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.
Changes
contents: write
permission todelete-branch
option in readmeContext
Updating readme to include a permission that is required for
delete-branch
option that is missing from the readme. Configuring this workflow with that additional permission should prevent issues like #587 from being raised again (#587 wasn't actually resolved, just closed by a bot due to inactivity).I have recently implemented this workflow in a repository configured with
delete-branch: true
. After the initial wait period, it started closing stale pull requests, but kept failing when trying to delete corresponding branches with the following errorError when deleting the branch "BRANCH_NAME" from pull request: Resource not accessible by integration
.Searching for answers I found the issue #587 mentioned above, where someone had the same problem, however no solution was provided there. Looking through the code, I found that this step is executed with the
deleteRef
action of the Octokit library, which in turn makes a request to the following GitHub REST API delete reference endpoint. According to GitHub REST API docs, that endpoint requirescontents: write
permission.As the recommended permissions mentioned in Stale readme are set to
issues: write
andpull-requests: write
, any other permissions that are absent from the list are set tonone
, therefore blockingdelete-branch
step from successfully executing.After adding
contents: write
permission to the workflow configuration, when Stale workflow closed the next stale pull request, it successfully deleted the corresponding branch.