88
99env :
1010 IMAGE_NAME : trafex/php-nginx
11+ IMAGE_TAG : ${{ github.sha }}
1112
1213jobs :
13- deploy :
14+ build :
1415 runs-on : ubuntu-latest
1516
1617 steps :
1718 - name : Checkout
1819 uses : actions/checkout@v2
1920
21+ - name : Set up QEMU
22+ uses : docker/setup-qemu-action@v1
23+
24+ - name : Set up Docker Buildx
25+ id : buildx
26+ uses : docker/setup-buildx-action@v1
27+
2028 - name : Build image
2129 run : |-
22- docker build -t $IMAGE_NAME .
23- docker tag $IMAGE_NAME:latest $IMAGE_NAME:${{ github.sha }}
30+ docker build -t $IMAGE_NAME:$IMAGE_TAG .
2431
2532 - name : Smoke test image
2633 run : |-
@@ -47,17 +54,26 @@ jobs:
4754 username : ${{ secrets.DOCKERHUB_USERNAME }}
4855 password : ${{ secrets.DOCKERHUB_TOKEN }}
4956
50- - name : Push latest image
57+ - name : Build multi-arch image and push latest tag
5158 if : github.ref == 'refs/heads/master' && github.event_name == 'push'
5259 run : |-
53- docker push $IMAGE_NAME:latest
60+ docker buildx build \
61+ --cache-from=$IMAGE_NAME:latest
62+ --push \
63+ -t $IMAGE_NAME:latest \
64+ --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
65+ .
5466
5567 - name : Set tag in environment
5668 if : contains(github.ref, 'refs/tags/')
5769 run : echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
5870
59- - name : Push tagged image
71+ - name : Build multi-arch image and push release tag
6072 if : contains(github.ref, 'refs/tags/')
6173 run : |-
62- docker tag $IMAGE_NAME:${{ github.sha }} $IMAGE_NAME:$RELEASE_VERSION
63- docker push $IMAGE_NAME:$RELEASE_VERSION
74+ docker buildx build \
75+ --cache-from=$IMAGE_NAME:latest
76+ --push \
77+ -t $IMAGE_NAME:$RELEASE_VERSION \
78+ --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
79+ .
0 commit comments