|
11 | 11 |
|
12 | 12 | jobs: |
13 | 13 | build: |
14 | | - name: Build |
15 | 14 | runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + packages: write |
| 18 | + id-token: write |
16 | 19 |
|
17 | 20 | steps: |
18 | 21 | - name: Checkout repository |
19 | | - uses: actions/checkout@v4 |
| 22 | + uses: actions/checkout@v5 |
20 | 23 |
|
21 | | - - name: Setup Docker buildx |
22 | | - uses: docker/setup-buildx-action@v3 |
| 24 | + - name: Install cosign |
| 25 | + if: github.event_name == 'release' |
| 26 | + uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad #v4.0.0 |
| 27 | + |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 #v3.11.1 |
23 | 30 |
|
24 | 31 | - name: Log into registry ${{ env.REGISTRY }} |
25 | | - uses: docker/login-action@v3 |
| 32 | + if: github.event_name == 'release' |
| 33 | + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef #v3.6.0 |
26 | 34 | with: |
27 | 35 | registry: ${{ env.REGISTRY }} |
28 | | - username: ${{ github.repository_owner }} |
| 36 | + username: ${{ github.actor }} |
29 | 37 | password: ${{ secrets.GITHUB_TOKEN }} |
30 | 38 |
|
31 | 39 | - name: Extract Docker metadata |
32 | 40 | id: meta |
33 | | - uses: docker/metadata-action@v5 |
| 41 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f #v5.8.0 |
34 | 42 | with: |
35 | 43 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
36 | 44 |
|
37 | 45 | - name: Build and push Docker image |
38 | | - uses: docker/build-push-action@v5 |
| 46 | + id: build-and-push |
| 47 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 #v6.18.0 |
39 | 48 | with: |
40 | 49 | context: . |
| 50 | + push: ${{ github.event_name == 'release' }} |
41 | 51 | labels: ${{ steps.meta.outputs.labels }} |
42 | | - platforms: linux/amd64 |
43 | | - push: true |
44 | 52 | tags: ${{ steps.meta.outputs.tags }} |
| 53 | + platforms: | |
| 54 | + linux/amd64 |
| 55 | + linux/arm64 |
| 56 | +
|
| 57 | + - name: Sign the published Docker image |
| 58 | + if: github.event_name == 'release' |
| 59 | + env: |
| 60 | + TAGS: ${{ steps.meta.outputs.tags }} |
| 61 | + DIGEST: ${{ steps.build-and-push.outputs.digest }} |
| 62 | + run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST} |
0 commit comments