$ cat "dev63.hatenablog.com/entry/2024/11/15/082427.md"
// ブログエントリー — 2024/11/15

fatal: unable to access 'https://github.com/username/reponame.git/': The requested URL returned error: 403

背景

以下のようなgithub actionsワークフローでpushができなかった。
fatal: unable to access 'https://github.com/username/reponame.git/': The requested URL returned error: 403 がエラーメッセージ。

- name: ワークフロー名
  env:
    PAT: ${{ secrets.ACTIONS_PAT }}
  run: |
    git remote set-url origin https://x-access-token:${PAT}@github.com/username/reponame.git
    git push origin main

解決策

「Settings」 > 「Actions」 > 「General」の、
Workflow permissions の設定を、
Read and write permissions に変更して解決。

ENTRY: dev63.hatenablog.com/entry/2024/11/15/082427.md
DATE: 2024/11/15
WORDS: 54