こんにちは、CX 事業本部 Delivery 部の若槻です。
おそらく GitHub Actions で最も使われているであろう actions/checkout
アクションですが、2023 年 9 月に V4 がリリースされていました。
現在の最新バージョンは v4.1.1 となっています。
V3 からの変更点
今回のリリースにより V3 から V4 へメジャーアップデートされた形となりますが、ソースコードの差分を見ると実装の抜本的な変更が行われたわけでなはなく、デフォルトの Nodejs ランタイムのバージョンを 16
から 20
にアップデートするに際して、破壊的変更を避けるためのアップデートのようです。
V3 の最新バージョン(v3.6.0)からの変更点は以下の通りです。
- Update to node20
- Support fetching without the --progress option
- Add support for partial checkout filters
試してみた
AWS CDK によるデプロイを行う CD/CD パイプラインの GitHub Actions ワークフローで、actions/checkout
アクションのバージョンを V3 から V4 に変更してみます。
.github/workflows/cicd.yml
on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
paths-ignore:
- "**/*.md"
- ".vscode/**"
- "packages/e2e/**"
- .github/dependabot.yml
- .github/workflows/add-issue-to-project.yml
jobs:
Integration:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Cache Dependency
uses: actions/cache@v3
id: cache_dependency
env:
cache-name: cache-dependency
with:
path: "**/node_modules"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
- name: Install Dependency
if: ${{ steps.cache_dependency.outputs.cache-hit != 'true' }}
run: npm ci --no-audit --progress=false --silent
- name: Lint & Format
run: |
npm run lint
npm run format
- name: tsc
run: npm run type-check-all
- name: Cdk Synth
run: npm run synth:dev
- name: Unit Test
run: npm run test-unit -- run
Deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
if: github.event.pull_request.merged == true
needs: Integration
permissions:
id-token: write
contents: read
env:
IS_BASE_REF_PRD: ${{ github.base_ref == 'main' }}
IS_BASE_REF_STG: ${{ github.base_ref == 'staging' }}
steps:
- name: Checkout
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
- name: Cache Dependency
uses: actions/cache@v3
id: cache_dependency
env:
cache-name: cache-dependency
with:
path: "**/node_modules"
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
- name: Assume Role
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: "ap-northeast-1"
role-to-assume: |
${{ env.IS_BASE_REF_PRD && vars.PRD_AWS_OIDC_ROLE_ARN || env.IS_BASE_REF_STG && vars.STG_AWS_OIDC_ROLE_ARN || vars.DEV_AWS_OIDC_ROLE_ARN }}
- name: Deploy
run: |
npm run deploy:${{ env.IS_BASE_REF_PRD && 'prd' || env.IS_BASE_REF_STG && 'stg' || 'dev' }}
ワークフローを実行すると、問題なく動作させることができました。
おわりに
actions/checkout アクションの V4 がリリースされていました。
現在は v3 が使われている環境が多いと思いますが、今後の actions/checkout のアップデートは V4 に対して行われることになると思いますので、早めに V4 への移行を行っておきたいですね。
以上