Open for commentsSelect text to comment
  • actions/create-github-app-token で発行されるトークンのスコープはowner / repositories / permission-* の指定の組み合わせで決まる。

ownerのみ指定するとinstallation全体スコープ

  • owner だけを指定すると、そのGitHub App installationがアクセスできる全リポジトリへの権限を持つトークンが発行される。
  • repositories も permission-* も未指定なら、インストール時に設定された権限がそのまま使われる。READMEにも次のように書かれている。

If owner is set and repositories is empty, access will be scoped to all repositories in the provided repository owner's installation.

- uses: actions/create-github-app-token@v2
  id: app-token
  with:
    app-id: ${{ secrets.APP_ID }}
    private-key: ${{ secrets.APP_PRIVATE_KEY }}
    owner: flier-inc

ownerを省略すると実行元リポジトリのみ

owner を省略した場合、デフォルトでワークフロー実行元リポジトリ(context.repo)だけにスコープが絞られる。複数リポジトリを操作したいワークフローでは注意。

If owner and repositories are empty, access will be scoped to only the current repository.

- uses: actions/create-github-app-token@v2
  id: app-token
  with:
    app-id: ${{ secrets.APP_ID }}
    private-key: ${{ secrets.APP_PRIVATE_KEY }}
    # ownerを指定しない場合は実行元リポジトリのみ

permission-*は未指定であれば引き継ぎ、指定あれば適用の上書きスタイル

  • permission-* は「all-or-nothing」ではない。

  • 正確には、一つでも permission-* を指定すると、指定していない権限は明示的に none として扱われる。

    • 一つも指定しなければ、GitHub App自体に設定された権限がそのまま全部使われる
    • 一つでも指定すると、指定した権限だけが有効になり、残りは自動的に除外される。App側でその権限を許可していてもトークンには含まれない
- uses: actions/create-github-app-token@v2
  id: app-token
  with:
    app-id: ${{ secrets.APP_ID }}
    private-key: ${{ secrets.APP_PRIVATE_KEY }}
    owner: flier-inc
    permission-contents: read
    # contents:read のみ有効。issuesやpull-requestsなど
    # App側で許可されている他の権限はすべてnoneになる

「必

References

Built with LogoFlowershow