1515
1616jobs :
1717 docker :
18- name : Docker Build and Push Image
18+ name : Docker Build and Push Image ${{ matrix.architecture }}
1919 runs-on : ubuntu-latest
20+ strategy :
21+ matrix :
22+ architecture : [arm64, amd64]
2023 steps :
2124 - name : Checkout repository
2225 uses : actions/checkout@v2
2730 fallback : latest
2831 - name : Set up QEMU
2932 uses : docker/setup-qemu-action@v1
33+ with :
34+ platforms : linux/${{ matrix.architecture }}
3035 - name : Set up docker buildx
3136 uses : docker/setup-buildx-action@v1
3237 with :
@@ -37,13 +42,51 @@ jobs:
3742 registry : ghcr.io
3843 username : ${{ github.actor }}
3944 password : ${{ secrets.GITHUB_TOKEN }}
45+ - name : Determine Base Image
46+ uses : haya14busa/action-cond@v1
47+ id : baseimage
48+ with :
49+ cond : ${{ matrix.architecture == 'arm64' }}
50+ if_true : ' swiftarm/swift:5.5.1-ubuntu-focal'
51+ if_false : ' swift:focal'
4052 - name : Build and push docker image
4153 id : buildandpush
4254 uses : docker/build-push-action@v2
4355 with :
4456 context : .
4557 file : ./Dockerfile
58+ build-args : |
59+ baseimage=${{ steps.baseimage.outputs.value }}
4660 push : true
47- tags : ghcr.io/apodini/template:latest,ghcr.io/apodini/template:${{ steps.latesttag.outputs.tag }}
61+ platforms : linux/${{ matrix.architecture }}
62+ tags : ghcr.io/apodini/template:latest-${{ matrix.architecture }},ghcr.io/apodini/template:${{ steps.latesttag.outputs.tag }}-${{ matrix.architecture }}
4863 - name : Image digest
4964 run : echo ${{ steps.buildandpush.outputs.digest }}
65+ dockermanifest :
66+ needs : [docker]
67+ name : Create Multi-CPU Architecture Image
68+ runs-on : ubuntu-latest
69+ steps :
70+ - name : Checkout repository
71+ uses : actions/checkout@v2
72+ - name : Get latest tag
73+ id : latesttag
74+ uses : WyriHaximus/github-action-get-previous-tag@v1
75+ with :
76+ fallback : latest
77+ - name : Log in to the container registry
78+ uses : docker/login-action@v1
79+ with :
80+ registry : ghcr.io
81+ username : ${{ github.actor }}
82+ password : ${{ secrets.GITHUB_TOKEN }}
83+ - name : Create and Push Multi Architecture Image
84+ run : |
85+ docker manifest create ghcr.io/apodini/template:latest \
86+ --amend ghcr.io/apodini/template:latest-amd64 \
87+ --amend ghcr.io/apodini/template:latest-arm64
88+ docker manifest create ghcr.io/apodini/template:${{ steps.latesttag.outputs.tag }} \
89+ --amend ghcr.io/apodini/template:${{ steps.latesttag.outputs.tag }}-amd64 \
90+ --amend ghcr.io/apodini/template:${{ steps.latesttag.outputs.tag }}-arm64
91+ docker manifest push ghcr.io/apodini/template:latest
92+ docker manifest push ghcr.io/apodini/template:${{ steps.latesttag.outputs.tag }}
0 commit comments