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

Add missing permissions to actions publish #16097

Merged
merged 2 commits into from Oct 9, 2023

Conversation

jameelkaisar
Copy link
Contributor

This commit enhances the publish actions script by including a step to close the pull request after
committing the changes. The existing script deletes the branch after pushing the commits, but lacks
the functionality to close the associated PR.

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Permissions Added:

  • contents: write
  • pull-requests: write

See: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

This commit enhances the publish actions script by
including a step to close the pull request after
committing the changes. The existing script deletes
the branch after pushing the commits, but lacks
the functionality to close the associated PR.
@Bo98
Copy link
Member

Bo98 commented Oct 8, 2023

brew pr-pull should already handle this without needing any extra permissions by modifying the commit message:

close_message = "Closes ##{pull_request}."
body += "\n\n#{close_message}" unless body.include? close_message
end
git_args = Utils::Git.git, "-C", git_repo.pathname, "commit", "--amend", "--signoff", "--allow-empty", "--quiet",
"--message", subject, "--message", body, "--message", trailers

@jameelkaisar
Copy link
Contributor Author

@Bo98 Yes, you are right, it is already been handled but I was getting some errors while testing this. The errors were due to missing permissions.

@Bo98
Copy link
Member

Bo98 commented Oct 8, 2023

Ah ok that makes more sense. So did you find that you could do just the permission changes without the gh pr close change?

This commit adds the missing permissions to the
actions publish script. The 'contents: write'
permission is required to publish releases and
the 'pull-requests: write' permission is required
to close the pull request after the changes are committed.
@jameelkaisar jameelkaisar changed the title Add close pr to actions publish Add missing permissions to actions publish Oct 8, 2023
@jameelkaisar
Copy link
Contributor Author

I looked into it and found out that the 'contents: write' permission is required to publish releases and the 'pull-requests: write' permission is required to close the pull request after the changes are committed. It seems like mentioning these permissions explicitly was not required in the past but now it is required.

See: https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

Copy link
Member

@Bo98 Bo98 left a comment

Choose a reason for hiding this comment

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

Makes sense. Thanks!

jameelkaisar added a commit to jameelkaisar/homebrew-tap that referenced this pull request Oct 8, 2023
Copy link
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

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

Thanks!

@carlocab carlocab merged commit a2d56ce into Homebrew:master Oct 9, 2023
27 checks passed
@MikeMcQuaid
Copy link
Member

Nice work everyone!

@jameelkaisar
Copy link
Contributor Author

Thanks 😊

@github-actions github-actions bot added the outdated PR was locked due to age label Nov 9, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants