Homebrew / actions

🚀 Homebrew's GitHub Actions
BSD 2-Clause "Simplified" License
122 stars 39 forks source link

Support using `secrets.GITHUB_TOKEN` for sending PRs #584

Closed Goooler closed 2 months ago

Goooler commented 2 months ago

I replaced the custom GitHub access token with ${{ secrets.GITHUB_TOKEN }} when using Homebrew/actions/bump-packages, which should be able to send PRs on GHA, but with an error:

Error: Failure while executing; `/usr/bin/env git push --set-upstream https://******@github.com/Goooler/homebrew-repo bump-kotlin-explorer-1.6.0:bump-kotlin-explorer-1.6.0` exited with 128. Here's the output:
fatal: could not read Password for 'https://***@github.com': Device not configured

Error: Failure while executing; `/usr/bin/env git push --set-upstream https://******@github.com/Goooler/homebrew-repo bump-kotlin-explorer-1.6.0:bump-kotlin-explorer-1.6.0` exited with 128. Here's the output:
fatal: could not read Password for 'https://***@github.com': Device not configured

It failed to create PR here, I believe we can replace this step with gh pr create ... for creating PRs on GitHub Actions, which uses GitHub official's GH CLI to do the same thing, without explicit PAT declared.

Goooler commented 2 months ago

According to Permissions for the GITHUB_TOKEN, it's able to send PRs on CI, the issue might be related to the wrong usage of it, fixing the usage will also resolve this issue.

Goooler commented 2 months ago
Error: Failure while executing; `/usr/bin/env git push --set-upstream ***github.com/Goooler/homebrew-repo bump-kotlin-explorer-1.6.0:bump-kotlin-explorer-1.6.0` exited with 1. Here's the output:
To https://github.com/Goooler/homebrew-repo
 ! [rejected]        bump-kotlin-explorer-1.6.0 -> bump-kotlin-explorer-1.6.0 (non-fast-forward)
error: failed to push some refs to 'https://github.com/Goooler/homebrew-repo'

https://github.com/Goooler/homebrew-repo/actions/runs/10700380504/job/29663997922

carlocab commented 2 months ago

Delete your bump-kotlin-explorer-1.6.0 branch and try again.

Goooler commented 2 months ago
Error: Unable to open pull request: GitHub API Error: Resource not accessible by integration
HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
  https://github.com/settings/tokens

https://github.com/Goooler/homebrew-repo/actions/runs/10700629318/job/29664778250

carlocab commented 2 months ago

Your GITHUB_TOKEN needs write access to pull requests.

Please use the discussions page if you need more help.