|
12 | 12 | dockerfile_path: |
13 | 13 | type: string |
14 | 14 | default: ./Dockerfile |
15 | | - platforms: |
16 | | - type: string |
17 | | - default: linux/amd64 |
18 | 15 | build_args: |
19 | 16 | type: string |
20 | 17 | run-trivy: |
|
30 | 27 |
|
31 | 28 | jobs: |
32 | 29 | build: |
33 | | - runs-on: ubuntu-latest |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + include: |
| 33 | + - runs-on: ubuntu-24.04 |
| 34 | + arch: amd64 |
| 35 | + - runs-on: ubuntu-24.04-arm |
| 36 | + arch: arm64 |
| 37 | + runs-on: ${{ matrix.runs-on }} |
34 | 38 | permissions: |
35 | 39 | contents: read |
36 | 40 | id-token: write |
|
54 | 58 | id: login-ecr |
55 | 59 | uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 |
56 | 60 |
|
| 61 | + - name: Build and push |
| 62 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 63 | + with: |
| 64 | + context: ./ |
| 65 | + file: ${{ inputs.dockerfile_path }} |
| 66 | + builder: ${{ steps.buildx.outputs.name }} |
| 67 | + push: true |
| 68 | + tags: ${{ steps.login-ecr.outputs.registry }}/${{ inputs.image_name }}:${{ github.sha }}-${{ matrix.arch }} |
| 69 | + provenance: false |
| 70 | + cache-from: type=gha,scope=${{ matrix.arch }} |
| 71 | + cache-to: type=gha,mode=max,scope=${{ matrix.arch }} |
| 72 | + build-args: ${{ inputs.build_args }} |
| 73 | + platforms: linux/${{ matrix.arch }} |
| 74 | + |
| 75 | + merge: |
| 76 | + needs: build |
| 77 | + runs-on: ubuntu-latest |
| 78 | + permissions: |
| 79 | + contents: read |
| 80 | + id-token: write |
| 81 | + timeout-minutes: 10 |
| 82 | + steps: |
| 83 | + - name: Configure AWS Credentials (OIDC) |
| 84 | + uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 |
| 85 | + with: |
| 86 | + role-to-assume: ${{ inputs.aws_role_to_assume }} |
| 87 | + aws-region: ${{ inputs.aws_region }} |
| 88 | + |
| 89 | + - name: Login to Amazon ECR |
| 90 | + id: login-ecr |
| 91 | + uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1 |
| 92 | + |
57 | 93 | - name: Check trigger type |
58 | 94 | id: check-trigger-type |
59 | 95 | shell: bash -xe {0} |
@@ -91,20 +127,18 @@ jobs: |
91 | 127 | prefix=branch-,type=ref,event=branch,enable=${{steps.check-trigger-type.outputs.enable_main}} |
92 | 128 | prefix=release-,type=ref,event=tag,enable=${{steps.check-trigger-type.outputs.enable_release}} |
93 | 129 |
|
94 | | - - name: Build |
95 | | - id: docker_build |
96 | | - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
97 | | - with: |
98 | | - context: ./ |
99 | | - file: ${{ inputs.DOCKERFILE_PATH }} |
100 | | - builder: ${{ steps.buildx.outputs.name }} |
101 | | - push: true |
102 | | - tags: ${{ steps.meta.outputs.tags }} |
103 | | - labels: ${{ steps.meta.outputs.labels }} |
104 | | - cache-from: type=gha |
105 | | - cache-to: type=gha,mode=max |
106 | | - build-args: ${{ inputs.build_args }} |
107 | | - platforms: ${{ inputs.platforms }} |
| 130 | + - name: Set up Docker Buildx |
| 131 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 132 | + |
| 133 | + - name: Create multi-arch manifest |
| 134 | + run: | |
| 135 | + image_base="${{ steps.login-ecr.outputs.registry }}/${{ inputs.image_name }}" |
| 136 | + for tag in ${{ steps.meta.outputs.tags }}; do |
| 137 | + docker buildx imagetools create \ |
| 138 | + --tag "${tag}" \ |
| 139 | + "${image_base}:${{ github.sha }}-amd64" \ |
| 140 | + "${image_base}:${{ github.sha }}-arm64" |
| 141 | + done |
108 | 142 | # trivyのスキャンが転けるのでコメントアウト |
109 | 143 | # - name: Run Trivy vulnerability scanner |
110 | 144 | # uses: aquasecurity/trivy-action@f9424c10c36e288d5fa79bd3dfd1aeb2d6eae808 # 0.33.0 |
|
0 commit comments