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

docs(readme): add missing permission for delete-branch option in readme #796

Merged

Conversation

dan-pavlov
Copy link
Contributor

Changes

  • add missing contents: write permission to delete-branch option in readme

Context

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 error Error when deleting the branch "BRANCH_NAME" from pull request: Resource not accessible by integration.

image

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 requires contents: write permission.

As the recommended permissions mentioned in Stale readme are set to issues: write and pull-requests: write, any other permissions that are absent from the list are set to none, therefore blocking delete-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.

image

@dan-pavlov dan-pavlov requested a review from a team as a code owner Aug 17, 2022
davorpa
davorpa approved these changes Sep 3, 2022
Copy link

@davorpa davorpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me

@luketomlinson luketomlinson merged commit 65afee9 into actions:main Sep 7, 2022
4 checks passed
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.

None yet

3 participants