|
1 | | -name: Publish Docker image |
| 1 | +name: Make release & publish Docker image |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | tags: |
6 | | - - 'v*.*.*' |
| 6 | + - 'v*' |
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | publish: |
10 | | - runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + runner-platform: |
| 13 | + - ubuntu-latest |
| 14 | + - self-hosted |
| 15 | + include: |
| 16 | + - runner-platform: ubuntu-latest |
| 17 | + build-arch: linux/amd64 |
| 18 | + tagged-platform: amd64 |
| 19 | + - runner-platform: self-hosted |
| 20 | + build-arch: linux/arm64 |
| 21 | + tagged-platform: arm64 |
| 22 | + runs-on: ${{ matrix.runner-platform }} |
11 | 23 | steps: |
12 | 24 | - name: Set up Buildx |
13 | 25 | uses: docker/setup-buildx-action@v1 |
14 | 26 |
|
15 | | - - name: Set up QEMU |
16 | | - uses: docker/setup-qemu-action@v1 |
17 | | - |
18 | 27 | - name: Cache Docker layers |
| 28 | + # AWS data transfer is pricy |
| 29 | + if: ${{ matrix.runner-platform != 'self-hosted' }} |
19 | 30 | uses: actions/cache@v2 |
20 | 31 | with: |
21 | 32 | path: /tmp/.buildx-cache |
22 | | - key: ${{ runner.os }}-buildx-${{ github.sha }} |
| 33 | + key: ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }}-${{ github.sha }} |
23 | 34 | restore-keys: | |
24 | | - ${{ runner.os }}-buildx- |
| 35 | + ${{ runner.os }}-buildx-prs-${{ matrix.build-arch }} |
25 | 36 |
|
26 | 37 | - name: Login to DockerHub |
27 | 38 | uses: docker/login-action@v1 |
28 | 39 | with: |
29 | 40 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
30 | 41 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
31 | 42 |
|
32 | | - - name: Limit concurrent builds to 1 |
33 | | - uses: softprops/turnstyle@v1 |
34 | | - env: |
35 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
36 | | - |
37 | 43 | - name: Build and push |
38 | 44 | id: docker_build |
39 | 45 | uses: docker/build-push-action@v2 |
40 | 46 | with: |
41 | 47 | push: true |
42 | | - tags: codetheweb/aoede:latest |
43 | | - platforms: linux/amd64,linux/arm64 |
| 48 | + tags: codetheweb/aoede:${{ github.sha }}-${{ matrix.tagged-platform }} |
| 49 | + platforms: ${{ matrix.build-arch }} |
44 | 50 | cache-from: type=local,src=/tmp/.buildx-cache |
45 | | - cache-to: type=local,dest=/tmp/.buildx-cache,mode=max |
| 51 | + cache-to: type=local,dest=/tmp/.buildx-cache,mode=min |
46 | 52 |
|
47 | | - - name: Update Docker Hub description |
48 | | - uses: peter-evans/dockerhub-description@v3 |
| 53 | + combine: |
| 54 | + name: Combine platform tags |
| 55 | + runs-on: ubuntu-latest |
| 56 | + needs: publish |
| 57 | + steps: |
| 58 | + - uses: actions/checkout@v1 |
| 59 | + |
| 60 | + - name: Set up Buildx |
| 61 | + uses: docker/setup-buildx-action@v1 |
| 62 | + |
| 63 | + - name: Login to DockerHub |
| 64 | + uses: docker/login-action@v1 |
49 | 65 | with: |
50 | 66 | username: ${{ secrets.DOCKERHUB_USERNAME }} |
51 | | - password: ${{ secrets.DOCKERHUB_PASSWORD }} |
52 | | - repository: codetheweb/aoede |
| 67 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 68 | + |
| 69 | + - name: Get tags |
| 70 | + id: get-tags |
| 71 | + uses: Surgo/docker-smart-tag-action@v1 |
| 72 | + with: |
| 73 | + docker_image: codetheweb/aoede |
| 74 | + |
| 75 | + - name: Combine tags |
| 76 | + run: docker buildx imagetools create $(echo '${{ steps.get-tags.outputs.tag }}' | tr "," "\0" | xargs -0 printf -- '-t %s ') 'codetheweb/aoede:${{ github.sha }}-arm64' 'codetheweb/aoede:${{ github.sha }}-amd64' |
| 77 | + |
| 78 | + - name: Update Docker Hub description |
| 79 | + uses: peter-evans/dockerhub-description@v2.4.3 |
| 80 | + env: |
| 81 | + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
| 82 | + DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 83 | + DOCKERHUB_REPOSITORY: codetheweb/aoede |
0 commit comments