1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[GitHub Actions] secrets.GITHUB_TOKENでプルリクが作れなくなったときの対応

Posted at

結論

Personal Access Token代わりに突っ込めば良い

経緯

をGitHub Actionsで以下のようにしていたが、突然使えなくなった。

.yml
    - name: Create a release pull request
      env:
        GIT_PR_RELEASE_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        GIT_PR_RELEASE_BRANCH_PRODUCTION: main
        GIT_PR_RELEASE_BRANCH_STAGING: develop
        GIT_PR_RELEASE_LABELS: release
        GIT_PR_RELEASE_TEMPLATE: .github/git_pr_release_template
      run: |
        gem install -N git-pr-release -v "2.1.1"
        git-pr-release --no-fetch
/opt/hostedtoolcache/Ruby/3.1.1/x64/lib/ruby/gems/3.1.0/gems/octokit-4.22.0/lib/octokit/response/raise_error.rb:14:in `on_complete': 
POST https://api.github.com/repos/(リポジトリ名)/pulls: 
403 - GitHub Actions is not permitted to create or approve pull requests. 
// See: https://docs.github.com/rest/reference/pulls#create-a-pull-request (Octokit::Forbidden)

GITHUB_TOKENの権限はSettingsでreadもwriteもOKにしてあった。
permissionsでwrite-allしてもダメだった。

対応

しかたがないので、Personal Access Token を発行。

secretsにつっこんだら動いた。

.yml
GIT_PR_RELEASE_TOKEN: ${{ secrets.GIT_PR_RELEASE_TOKEN }}
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?