peaceiris/actions-gh-pagesでrepository not foundと怒られる
結論: authentication token permissionを与えろ
GitHub ActionsからGitHub Pagesを更新するべくpeaceiris/actions-gh-pagesでデプロイしようとしたらrepository not foundと怒られた。
code:error
Push the commit or tag
/usr/bin/git push origin gh-pages
remote: Repository not found.
fatal: repository 'https://github.com/XXX/YYY.git/' not found
Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"
github actions push repository not found とかでググるとこういう記事が出てくる: https://zenn.dev/m_norii/articles/349b9ce0260631
確かにPATを渡すと成功したが、どう考えてもPATのまま運用に載せたくない。
エラーログを睨んでいる内に「push時にnot foundが出るっていうことは権限が足りていない可能性はないか」と思い当たった。
動かしていたリポジトリはprivateで、非公開のリソースに対する操作の権限が不足している場合にリソースの存在を知らせないようなエラーメッセージを返すことはありうるし、push権限を持っている自分のPATを使うことで解決することとも符号する。
最近OIDC関連でトークンのpermissionという概念が登場したなと思い、ドキュメントをあたる: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
GitHub Pagesのデプロイはリポジトリへの git push なので contents を見る。permissiveだとデフォルトはwriteが付いているが、restrictedだとreadなのでかなり怪しい。
オーガニゼーションの設定を見たらデフォルトがreadになっていた。というか「安全のために変えておきましょう」って提案して作業したのは自分だった……。
GitHub Pagesにデプロイするジョブに pemissions: { contents: write } を追加し解決。