AWS CodeBuild Run Build for GitHub Actions (aws-actions/aws-codebuild-run-build
) を使うと GitHub Actions から AWS CodeBuild のビルドを実行できる👌
シンプルに AWS CodeBuild のビルドを実行するだけなら project-name
パラメータを指定すれば良くて簡単〜 \( 'ω')/
name: Start AWS CodeBuild build on: workflow_dispatch: push: branches: - master pull_request: branches: - master permissions: id-token: write contents: read jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ROLE_ARN }} aws-region: ap-northeast-1 - name: Start AWS CodeBuild build uses: aws-actions/aws-codebuild-run-build@v1 with: project-name: sandbox
ちなみに GitHub Actions で AWS アカウントの権限を取得する仕組みは以下の記事にまとめてある!
もし GitHub リポジトリをモノリポ構成(例えば Yarn Workspaces など)で運用していて,アプリケーションごとに AWS CodeBuild を作らず共有するという選択肢もあると思う.
buildspec-override
パラメータに packgages/app1/buildspec.yml
などアプリケーションごとの buildspec.yml
を設定すれば OK👌 さらにアプリケーションごとにビルド環境に必要なスペックが異なる場合は compute-type-override
パラメータで BUILD_GENERAL1_SMALL
や BUILD_GENERAL1_MEDIUM
などの環境タイプを設定すれば OK👌柔軟に AWS CodeBuild のビルドを実行できて便利❗️
name: Start AWS CodeBuild build on: workflow_dispatch: push: branches: - master pull_request: branches: - master permissions: id-token: write contents: read jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: ${{ secrets.AWS_ROLE_ARN }} aws-region: ap-northeast-1 - name: Start AWS CodeBuild build / app1 uses: aws-actions/aws-codebuild-run-build@v1 with: project-name: sandbox buildspec-override: packgages/app1/buildspec.yml - name: Start AWS CodeBuild build / app2 uses: aws-actions/aws-codebuild-run-build@v1 with: project-name: sandbox buildspec-override: packgages/app2/buildspec.yml - name: Start AWS CodeBuild build / app3 uses: aws-actions/aws-codebuild-run-build@v1 with: project-name: sandbox buildspec-override: packgages/app3/buildspec.yml compute-type-override: BUILD_GENERAL1_MEDIUM