|
16 | 16 | # github.repository as <account>/<repo> |
17 | 17 | IMAGE_NAME: ${{ github.repository }} |
18 | 18 |
|
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
19 | 23 | jobs: |
20 | 24 | build: |
21 | 25 | runs-on: ubuntu-latest |
22 | 26 | permissions: |
23 | 27 | contents: read |
24 | 28 | packages: write |
| 29 | + strategy: |
| 30 | + fail-fast: false |
| 31 | + matrix: |
| 32 | + platform: |
| 33 | + - linux/amd64 |
| 34 | + - linux/arm64/v8 |
25 | 35 |
|
26 | 36 | steps: |
27 | 37 | - name: Checkout repository |
@@ -55,22 +65,67 @@ jobs: |
55 | 65 | env: |
56 | 66 | SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
57 | 67 | if: ${{ env.SENTRY_AUTH_TOKEN != '' }} |
58 | | - run: "echo SENTRY_AUTH_TOKEN=\"$SENTRY_AUTH_TOKEN\" > frontend/.env.sentry-build-plugin" |
| 68 | + run: 'echo SENTRY_AUTH_TOKEN="$SENTRY_AUTH_TOKEN" > frontend/.env.sentry-build-plugin' |
59 | 69 |
|
60 | 70 | # Build and push Docker image with Buildx (don't push on PR) |
61 | 71 | # https://github.com/docker/build-push-action |
62 | 72 | - name: Build and push Docker image |
63 | | - id: build-and-push |
| 73 | + id: build |
64 | 74 | uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 |
65 | 75 | with: |
66 | 76 | context: . |
67 | | - push: ${{ github.event_name != 'pull_request' }} |
68 | | - tags: ${{ steps.meta.outputs.tags }} |
69 | 77 | labels: ${{ steps.meta.outputs.labels }} |
70 | 78 | cache-from: type=gha |
71 | 79 | cache-to: type=gha,mode=max |
72 | | - platforms: linux/amd64,linux/arm64/v8 |
| 80 | + platforms: ${{ matrix.platform }} |
73 | 81 | provenance: true |
74 | 82 | sbom: true |
75 | | - build-args: | |
76 | | - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} |
| 83 | + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=${{ !github.event.pull_request || github.event.pull_request.base.repo == github.event.pull_request.head.repo }} |
| 84 | + - name: Export digest |
| 85 | + if: ${{ !github.event.pull_request || github.event.pull_request.base.repo == github.event.pull_request.head.repo }} |
| 86 | + run: | |
| 87 | + mkdir -p /tmp/digests |
| 88 | + digest="${{ steps.build.outputs.digest }}" |
| 89 | + touch "/tmp/digests/${digest#sha256:}" |
| 90 | + - name: Upload digest |
| 91 | + if: ${{ !github.event.pull_request || github.event.pull_request.base.repo == github.event.pull_request.head.repo }} |
| 92 | + uses: actions/upload-artifact@v3 |
| 93 | + with: |
| 94 | + name: digests |
| 95 | + path: /tmp/digests/* |
| 96 | + if-no-files-found: error |
| 97 | + retention-days: 1 |
| 98 | + merge: |
| 99 | + runs-on: ubuntu-latest |
| 100 | + if: ${{ !github.event.pull_request || github.event.pull_request.base.repo == github.event.pull_request.head.repo }} |
| 101 | + needs: |
| 102 | + - build |
| 103 | + permissions: |
| 104 | + packages: write |
| 105 | + steps: |
| 106 | + - name: Download digests |
| 107 | + uses: actions/download-artifact@v3 |
| 108 | + with: |
| 109 | + name: digests |
| 110 | + path: /tmp/digests |
| 111 | + - name: Set up Docker Buildx |
| 112 | + uses: docker/setup-buildx-action@v3 |
| 113 | + - name: Docker meta |
| 114 | + id: meta |
| 115 | + uses: docker/metadata-action@v5 |
| 116 | + with: |
| 117 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 118 | + - name: Log into registry ${{ env.REGISTRY }} |
| 119 | + uses: docker/login-action@v3.0.0 |
| 120 | + with: |
| 121 | + registry: ${{ env.REGISTRY }} |
| 122 | + username: ${{ github.actor }} |
| 123 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + - name: Create manifest list and push |
| 125 | + working-directory: /tmp/digests |
| 126 | + run: | |
| 127 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 128 | + $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *) |
| 129 | + - name: Inspect image |
| 130 | + run: | |
| 131 | + docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }} |
0 commit comments