GitHub Actionsのpermissionsはエンドポイントではなくリソースで判断される
#GitHub
どういうことかというと、IssuesとPull Requestsで共通のAPIは、その対象がIssueなのかPull Requestなのかによって必要な権限が変わる。
たとえばIssueのラベルを取得するこういうエンドポイントは、Pull Requestのラベルであっても同じものを使う。
https://octokit.github.io/rest.js/v20#issues-list-labels-on-issue
https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#about-labels
Every pull request is an issue, but not every issue is a pull request.
しかしGitHub Actionsの permissions で指定する権限は、ラベルを取得する対象がIssueであれば issues: read を、Pull Requestであれば pull-requests: read を要求する。
https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
issues
Work with issues. For example, issues: write permits an action to add a comment to an issue. For more information, see "Permissions required for GitHub Apps."
pull-requests
Work with pull requests. For example, pull-requests: write permits an action to add a label to a pull request. For more information, see "Permissions required for GitHub Apps."
つまり、GitHub Actionsのpermissionsはエンドポイントではなくリソースで判断される。難しい。