Skip to content

Commit c52003a

Browse files
committed
build amd64 and arm64 on appropriate os architecture
1 parent b42d197 commit c52003a

File tree

1 file changed

+102
-23
lines changed

1 file changed

+102
-23
lines changed
Lines changed: 102 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: Docker Images - Pull Request
22
on: pull_request
33

4+
env:
5+
REGISTRY_ALIAS: w0i8p0z9
46
jobs:
57
# hadolint:
68
# name: Lint Dockerfiles
@@ -11,7 +13,7 @@ jobs:
1113
# with:
1214
# recursive: true
1315

14-
chkmodified:
16+
check-modified:
1517
name: Check modified
1618
runs-on: ubuntu-latest
1719
outputs:
@@ -32,33 +34,110 @@ jobs:
3234
env:
3335
CHANGED_FILES: ${{ steps.get_changed_files.outputs.all_modified_files }}
3436

35-
build-public:
36-
needs: chkmodified
37-
runs-on: ubuntu-24.04-arm
38-
environment: ecr-prod-publish
39-
permissions:
40-
id-token: write
41-
contents: read
37+
build-amd64:
38+
name: Build & Push AMD64 Image
39+
runs-on: ubuntu-latest # Ensure it supports x86_64
40+
needs: [ check-modified ]
4241
strategy:
43-
matrix: ${{ fromJson(needs.chkmodified.outputs.dockerfile_dirs) }}
42+
matrix: ${{ fromJson(needs.check-modified.outputs.dockerfile_dirs) }}
4443
fail-fast: false
45-
4644
steps:
47-
- name: Build
48-
uses: smartcontractkit/.github/actions/cicd-build-publish-docker@main # v0.1.0
45+
- name: Checkout Code
46+
uses: actions/checkout@v4
47+
48+
- name: Configure AWS Credentials
49+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
50+
with:
51+
aws-region: us-east-1
52+
role-to-assume: ${{ secrets.AWS_OIDC_PUBLISH_ECR_ROLE_ARN }}
53+
54+
- name: Login to Amazon ECR
55+
id: login-ecr
56+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
57+
with:
58+
registry-type: 'public'
59+
registries: ${{ secrets.AWS_PROD_ACCOUNT_NUMBER }}
60+
61+
- name: Set up Docker Buildx
62+
uses: docker/setup-buildx-action@v3
63+
64+
- name: Build and Push AMD64 Image
65+
uses: docker/build-push-action@v5
4966
with:
50-
# general inputs
51-
ecr-repo-name: ${{ matrix.image }}
52-
publish: 'false'
53-
dockerfile: ./images/${{ matrix.image }}/Dockerfile
5467
context: ./images/${{ matrix.image }}/
68+
file: ./images/${{ matrix.image }}/Dockerfile
69+
push: true
70+
platforms: linux/amd64
71+
tags: |
72+
${{ steps.login-ecr.outputs.registry }}/${ env.REGISTRY_ALIAS }/${{ matrix.image }}:sha-${{ github.sha }}-amd64
73+
cache-from: type=gha
74+
cache-to: type=gha,mode=max
75+
76+
build-arm64:
77+
name: Build & Push Arm64 Image
78+
runs-on: ubuntu-24.04-arm # Ensure it supports x86_64
79+
needs: [ check-modified ]
80+
strategy:
81+
matrix: ${{ fromJson(needs.check-modified.outputs.dockerfile_dirs) }}
82+
fail-fast: false
83+
steps:
84+
- name: Checkout Code
85+
uses: actions/checkout@v4
86+
87+
- name: Configure AWS Credentials
88+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
89+
with:
90+
aws-region: us-east-1
91+
role-to-assume: ${{ secrets.AWS_OIDC_PUBLISH_ECR_ROLE_ARN }}
92+
93+
- name: Login to Amazon ECR
94+
id: login-ecr
95+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
96+
with:
5597
registry-type: 'public'
56-
registry-alias: 'w0i8p0z9'
57-
multi-platform: 'true'
58-
# platforms: linux/amd64,linux/arm64
98+
registries: ${{ secrets.AWS_PROD_ACCOUNT_NUMBER }}
99+
100+
- name: Set up Docker Buildx
101+
uses: docker/setup-buildx-action@v3
102+
103+
- name: Build and Push Arm64 Image
104+
uses: docker/build-push-action@v5
105+
with:
106+
context: ./images/${{ matrix.image }}/
107+
file: ./images/${{ matrix.image }}/Dockerfile
108+
push: true
59109
platforms: linux/arm64
60110
tags: |
61-
type=sha,prefix=pr=,event=pr
62-
# aws inputs
63-
aws-role-arn: ${{ secrets.AWS_OIDC_PUBLISH_ECR_ROLE_ARN }}
64-
aws-account-number: ${{ secrets.AWS_PROD_ACCOUNT_NUMBER }}
111+
${{ steps.login-ecr.outputs.registry }}/${ env.REGISTRY_ALIAS }/${{ matrix.image }}:sha-${{ github.sha }}-arm64
112+
cache-from: type=gha
113+
cache-to: type=gha,mode=max
114+
115+
create-manifest:
116+
name: Create & Push Multi-Arch Manifest
117+
runs-on: ubuntu-latest
118+
strategy:
119+
matrix: ${{ fromJson(needs.check-modified.outputs.dockerfile_dirs) }}
120+
fail-fast: false
121+
needs: [check-modified, build-amd64, build-arm64]
122+
steps:
123+
- name: Configure AWS Credentials
124+
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
125+
with:
126+
aws-region: us-east-1
127+
role-to-assume: ${{ secrets.AWS_OIDC_PUBLISH_ECR_ROLE_ARN }}
128+
129+
- name: Login to Amazon ECR
130+
id: login-ecr
131+
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
132+
with:
133+
registry-type: 'public'
134+
registries: ${{ secrets.AWS_PROD_ACCOUNT_NUMBER }}
135+
136+
- name: Create and Push Multi-Architecture Manifest
137+
run: |
138+
docker manifest create ${{ steps.login-ecr.outputs.registry }}/${ env.REGISTRY_ALIAS }/${{ matrix.image }}:sha-${{ github.sha }} \
139+
--amend ${{ steps.login-ecr.outputs.registry }}/${ env.REGISTRY_ALIAS }/${{ matrix.image }}:sha-${{ github.sha }}-amd64 \
140+
--amend ${{ steps.login-ecr.outputs.registry }}/${ env.REGISTRY_ALIAS }/${{ matrix.image }}:sha-${{ github.sha }}-arm64
141+
142+
docker manifest push ${{ steps.login-ecr.outputs.registry }}/${ env.REGISTRY_ALIAS }/${{ matrix.image }}:sha-${{ github.sha }}
143+

0 commit comments

Comments
 (0)