8
8
9
9
env :
10
10
IMAGE_NAME : trafex/php-nginx
11
+ IMAGE_TAG : ${{ github.sha }}
11
12
12
13
jobs :
13
- deploy :
14
+ build :
14
15
runs-on : ubuntu-latest
15
16
16
17
steps :
17
18
- name : Checkout
18
19
uses : actions/checkout@v2
19
20
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
+
20
28
- name : Build image
21
29
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 .
24
31
25
32
- name : Smoke test image
26
33
run : |-
@@ -47,17 +54,26 @@ jobs:
47
54
username : ${{ secrets.DOCKERHUB_USERNAME }}
48
55
password : ${{ secrets.DOCKERHUB_TOKEN }}
49
56
50
- - name : Push latest image
57
+ - name : Build multi-arch image and push latest tag
51
58
if : github.ref == 'refs/heads/master' && github.event_name == 'push'
52
59
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
+ .
54
66
55
67
- name : Set tag in environment
56
68
if : contains(github.ref, 'refs/tags/')
57
69
run : echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
58
70
59
- - name : Push tagged image
71
+ - name : Build multi-arch image and push release tag
60
72
if : contains(github.ref, 'refs/tags/')
61
73
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