4
1

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 3 years have passed since last update.

GitHub Actions で submodule チェックアウトを GitHub Apps にお願いする

Last updated at Posted at 2021-08-12

はじめに

PersonalAccessToken(PAT) や SSH 接続による submodule チェックアウトではなく、
ここでは GitHub Apps で認証しチェックアウトします。

事前準備

手順は割愛します。

  • GitHub Appを作成する
    • ContentsRead-only Permission を付与する
  • GitHub Actions secretsに以下2つの値を登録する
    • APP_ID (GitHub App のApp ID)
    • APP_PRIVATE_KEY (GitHub App の Private Key)

ワークフローの定義

早速完成版です。

name: git submodule
on:
  workflow_dispatch:
jobs:
  pre:
    name: pre
    runs-on: ubuntu-20.04
    steps:
      - name: github-app-access-token
        id: get-github-app
        uses: getsentry/action-github-app-token@v1
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
      - name: Checkout
        uses: actions/checkout@v2
        with:
          submodules: recursive
          token: ${{ steps.get-github-app.outputs.token }}
      - name: print
        run: |
          ls -la
          ls -la example-github-actions-sub

アクセストークンを取得する

GitHub Appのアクセストークンを取得するActionはMarketplaceにいくつかありますが、こちらでは以下を使いました。

GitHub Actions secrets から App IDPrivate Key をセットし、トークンを取得します。
取得されたトークンは出力パラメータで後続で受け取ります。

チェックアウト

submodulerecursive に設定し、再起的にサブモジュールをチェックアウトします。
また、 token に先行処理で取得したトークンをセットします。

結果

最後にチェックアウトされたことを確認します。

image.png

4
1
0

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
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?