|
5 | 5 | branches:
|
6 | 6 | - main
|
7 | 7 |
|
| 8 | +env: |
| 9 | + REGISTRY: ghcr.io |
| 10 | + IMAGE_NAME: ${{ github.repository }} |
| 11 | + |
8 | 12 | jobs:
|
9 | 13 | build-and-publish:
|
10 | 14 | runs-on: ubuntu-latest
|
11 | 15 |
|
| 16 | + permissions: |
| 17 | + contents: read |
| 18 | + packages: write |
| 19 | + attestations: write |
| 20 | + id-token: write |
| 21 | + |
12 | 22 | steps:
|
13 | 23 | - name: Checkout code
|
14 | 24 | uses: actions/checkout@v4
|
15 | 25 |
|
16 |
| - # Add support for more platforms with QEMU (optional) |
17 |
| - # https://github.com/docker/setup-qemu-action |
18 |
| - # - name: Set up QEMU |
19 |
| - # uses: docker/setup-qemu-action@v3 |
20 |
| - |
21 |
| - - name: Set up Docker Buildx |
22 |
| - uses: docker/setup-buildx-action@v3 |
23 |
| - |
24 |
| - - name: Log in to GitHub Container Registry |
25 |
| - uses: docker/login-action@v3 |
| 26 | + - name: Log in to the Container registry |
| 27 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
26 | 28 | with:
|
27 |
| - registry: ghcr.io |
| 29 | + registry: ${{ env.REGISTRY }} |
28 | 30 | username: ${{ github.actor }}
|
29 |
| - password: ${{ secrets.GH_PAT }} |
| 31 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 32 | + |
| 33 | + - name: Extract metadata (tags, labels) for Docker |
| 34 | + id: meta |
| 35 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 36 | + with: |
| 37 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
30 | 38 |
|
31 | 39 | - name: Build and push Docker image
|
32 |
| - uses: docker/build-push-action@v6 |
| 40 | + id: push |
| 41 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
33 | 42 | with:
|
34 | 43 | context: .
|
35 | 44 | push: true
|
36 |
| - tags: ghcr.io/${{ github.actor }}/qna-admin:latest |
| 45 | + tags: ${{ steps.meta.outputs.tags }} |
| 46 | + labels: ${{ steps.meta.outputs.labels }} |
| 47 | + |
| 48 | + - name: Generate artifact attestation |
| 49 | + uses: actions/attest-build-provenance@v1 |
| 50 | + with: |
| 51 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} |
| 52 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 53 | + push-to-registry: true |
0 commit comments