1111 IMAGE_NAME : ${{ github.repository }}
1212
1313jobs :
14- build-and-push :
15- runs-on : ubuntu-22.04
14+ build-arm64 :
15+ runs-on : ubuntu-22.04-arm
1616 steps :
1717 - name : Check out repository
1818 uses : actions/checkout@v3
@@ -32,16 +32,47 @@ jobs:
3232 username : ${{ github.repository_owner }}
3333 password : ${{ secrets.GITHUB_TOKEN }}
3434
35- - name : Build and export to Docker
35+ - name : Get next tag
36+ id : tag
37+ run : |
38+ git fetch --all --tags
39+ git tag -l
40+ NEW_TAG=v$(date +'%Y.%m')
41+ FOUND=$(git tag -l | grep $NEW_TAG | wc -l)
42+ if [ $FOUND -eq 0 ]; then
43+ echo "TAG=$NEW_TAG" >> $GITHUB_OUTPUT
44+ else
45+ echo "TAG=$NEW_TAG-$FOUND" >> $GITHUB_OUTPUT
46+ fi
47+
48+ - name : Build and push
3649 uses : docker/build-push-action@v6
3750 with :
38- load : true
51+ platforms : linux/arm64
52+ push : true
3953 context : ./
40- tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
54+ tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}-arm64
4155
42- - name : Test
43- run : |
44- docker run --rm -e "TEST=1" ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test
56+ build-amd64 :
57+ runs-on : ubuntu-22.04
58+ steps :
59+ - name : Check out repository
60+ uses : actions/checkout@v3
61+ with :
62+ submodules : ' recursive'
63+
64+ - name : Set up QEMU
65+ 66+
67+ - name : Set up Docker Buildx
68+ 69+
70+ - name : Login to GitHub Container Registry
71+ uses : docker/login-action@v3
72+ with :
73+ registry : ${{ env.REGISTRY }}
74+ username : ${{ github.repository_owner }}
75+ password : ${{ secrets.GITHUB_TOKEN }}
4576
4677 - name : Get next tag
4778 id : tag
@@ -57,12 +88,52 @@ jobs:
5788 fi
5889
5990 - name : Build and push
60- id : docker_build
6191 uses : docker/build-push-action@v6
6292 with :
63- platforms : linux/amd64,linux/arm64
93+ platforms : linux/amd64
6494 push : true
6595 context : ./
66- tags : |
67- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
68- ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}
96+ tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}-amd64
97+
98+ merge :
99+ runs-on : ubuntu-22.04
100+ needs :
101+ - build-amd64
102+ - build-arm64
103+ steps :
104+ - name : Check out repository
105+ uses : actions/checkout@v3
106+
107+ - name : Get next tag
108+ id : tag
109+ run : |
110+ git fetch --all --tags
111+ git tag -l
112+ NEW_TAG=v$(date +'%Y.%m')
113+ FOUND=$(git tag -l | grep $NEW_TAG | wc -l)
114+ if [ $FOUND -eq 0 ]; then
115+ echo "TAG=$NEW_TAG" >> $GITHUB_OUTPUT
116+ else
117+ echo "TAG=$NEW_TAG-$FOUND" >> $GITHUB_OUTPUT
118+ fi
119+
120+ - name : Login to GitHub Container Registry
121+ uses : docker/login-action@v3
122+ with :
123+ registry : ${{ env.REGISTRY }}
124+ username : ${{ github.repository_owner }}
125+ password : ${{ secrets.GITHUB_TOKEN }}
126+
127+ - name : Set up Docker Buildx
128+ 129+
130+ - name : Create manifest list and push
131+ run : |
132+ docker buildx imagetools create \
133+ --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
134+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}-arm64 \
135+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.TAG }}-amd64
136+
137+ - name : Inspect image
138+ run : |
139+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
0 commit comments