3030 IMAGE_SLUG : ${{ github.repository }}
3131
3232jobs :
33- # Push image to GitHub Container Registry.
33+ # Generate shared tags for both architectures
3434 # The image tag pattern is:
3535 # for pull-requests: <PATCH_VERSION>-<DATE>-<PR_NUMBER>, eg: 1.35.2-20210125-25
3636 # for tags: <TAG>
3737 # for `master` branch: latest,<PATCH_VERSION>-latest,<MINOR_VERSION>-latest,<MAJOR_VERSION>-latest,<PATCH_VERSION>-<DATE>-<SHA>
3838 # for `development` branch: development,<MAJOR_VERSION>-development,<PATCH_VERSION>-<DATE>-<SHA>
3939 # for releases: release,<PATCH_VERSION>-release,<MINOR_VERSION>-release,<MAJOR_VERSION>-release,<PATCH_VERSION>-<DATE>-<SHA>
4040 # Version is parsed from package.json
41- push :
41+ generate-tags :
4242 runs-on : ubuntu-latest
4343 if : github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'release'
44+ outputs :
45+ registry-tags : ${{ steps.generate.outputs.REGISTRY_TAGS }}
46+ image-id : ${{ steps.generate.outputs.IMAGE_ID }}
4447 steps :
4548 - name : Checkout
4649 uses : actions/checkout@v3
@@ -83,13 +86,13 @@ jobs:
8386 [ "$VERSION" == "development" ] && VERSION=development
8487 [ "${{ github.event_name }}" == "release" ] && VERSION=release
8588
86- # Compose REGISTRY_TAGS variable
87- REGISTRY_TAGS="-t $IMAGE_ID:$VERSION"
89+ # Compose REGISTRY_TAGS variable for buildx (space-separated with --tag flags)
90+ REGISTRY_TAGS="--tag $IMAGE_ID:$VERSION"
8891
8992 # For master branch also supply an extra tag: <PATCH_VERSION>-latest,<MINOR_VERSION>-latest,<MAJOR_VERSION>-latest,<PATCH_VERSION>-<DATE>-<SHA>
90- [ "$VERSION" == "latest" ] && REGISTRY_TAGS="$REGISTRY_TAGS -t $IMAGE_ID:$PATCH_VERSION-latest -t $IMAGE_ID:$MINOR_VERSION-latest -t $IMAGE_ID:$MAJOR_VERSION-latest -t $IMAGE_ID:$PATCH_VERSION-$BDATE-$(git rev-parse --short HEAD)"
91- [ "$VERSION" == "development" ] && REGISTRY_TAGS="$REGISTRY_TAGS -t $IMAGE_ID:$MAJOR_VERSION-development -t $IMAGE_ID:$PATCH_VERSION-$BDATE-$(git rev-parse --short HEAD)"
92- [ "$VERSION" == "release" ] && REGISTRY_TAGS="$REGISTRY_TAGS -t $IMAGE_ID:$PATCH_VERSION-release -t $IMAGE_ID:$MINOR_VERSION-release -t $IMAGE_ID:$MAJOR_VERSION-release -t $IMAGE_ID:$PATCH_VERSION-$BDATE-$(git rev-parse --short HEAD)"
93+ [ "$VERSION" == "latest" ] && REGISTRY_TAGS="$REGISTRY_TAGS --tag $IMAGE_ID:$PATCH_VERSION-latest --tag $IMAGE_ID:$MINOR_VERSION-latest --tag $IMAGE_ID:$MAJOR_VERSION-latest --tag $IMAGE_ID:$PATCH_VERSION-$BDATE-$(git rev-parse --short HEAD)"
94+ [ "$VERSION" == "development" ] && REGISTRY_TAGS="$REGISTRY_TAGS --tag $IMAGE_ID:$MAJOR_VERSION-development --tag $IMAGE_ID:$PATCH_VERSION-$BDATE-$(git rev-parse --short HEAD)"
95+ [ "$VERSION" == "release" ] && REGISTRY_TAGS="$REGISTRY_TAGS --tag $IMAGE_ID:$PATCH_VERSION-release --tag $IMAGE_ID:$MINOR_VERSION-release --tag $IMAGE_ID:$MAJOR_VERSION-release --tag $IMAGE_ID:$PATCH_VERSION-$BDATE-$(git rev-parse --short HEAD)"
9396
9497 echo IMAGE_ID=$IMAGE_ID
9598 echo VERSION=$VERSION
@@ -99,19 +102,58 @@ jobs:
99102 SHA_SHORT=${{ github.sha }}
100103 [ "${{ github.event_name }}" == "pull_request" ] && SHA_SHORT=$(echo ${{ github.event.pull_request.head.sha }} | cut -c1-8)
101104
102- echo "Final image tag to be pushed:"
105+ echo "Final image tags to be pushed:"
103106 echo $REGISTRY_TAGS
104107 echo "REGISTRY_TAGS=$REGISTRY_TAGS" >> $GITHUB_OUTPUT
105108 echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_OUTPUT
106109 echo "REGISTRY_TAGS_VERSION=$VERSION" >> $GITHUB_OUTPUT
107110 echo "REGISTRY_TAGS_PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
108111 echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_OUTPUT
109112
113+ # Build and push AMD64 image on x64 runner
114+ build-amd64 :
115+ needs : generate-tags
116+ runs-on : ubuntu-latest # x64 runner for native AMD64 builds
117+ steps :
118+ - name : Checkout
119+ uses : actions/checkout@v3
120+
121+ - name : Set up Docker Buildx
122+ uses : docker/setup-buildx-action@v3
123+
110124 - name : Login to GHCR
111125 run : echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ghcr.io
112126
113- - name : Docker build
114- run : docker build --no-cache ${{ steps.generate.outputs.REGISTRY_TAGS }} .
127+ - name : Docker buildx build and push (AMD64)
128+ run : |
129+ docker buildx build \
130+ --platform linux/amd64 \
131+ ${{ needs.generate-tags.outputs.registry-tags }} \
132+ --push \
133+ --no-cache \
134+ .
135+
136+ # Build and push ARM64 image on ARM64 runner
137+ build-arm64 :
138+ needs : generate-tags
139+ runs-on : ubuntu-24.04-arm # ARM64 runner for native ARM64 builds
140+ steps :
141+ - name : Checkout
142+ uses : actions/checkout@v3
115143
116- - name : Docker push
117- run : docker push ${{ steps.generate.outputs.IMAGE_ID }} --all-tags
144+ - name : Set up Docker Buildx
145+ uses : docker/setup-buildx-action@v3
146+
147+ - name : Login to GHCR
148+ run : echo ${{ secrets.GITHUB_TOKEN }} | docker login -u ${{ github.actor }} --password-stdin ghcr.io
149+
150+ - name : Docker buildx build and push (ARM64)
151+ run : |
152+ # Generate ARM64-specific tags by adding -arm64 suffix
153+ ARM64_TAGS="${{ needs.generate-tags.outputs.registry-tags }}-arm64"
154+ docker buildx build \
155+ --platform linux/arm64 \
156+ ${ARM64_TAGS} \
157+ --push \
158+ --no-cache \
159+ .
0 commit comments