|
6 | 6 | pull_request: |
7 | 7 | branches: [ "main" ] |
8 | 8 |
|
| 9 | +env: |
| 10 | + REGISTRY: ghcr.io |
| 11 | + IMAGE_NAME: ${{ github.repository }} |
| 12 | + |
9 | 13 | jobs: |
10 | 14 |
|
11 | 15 | build: |
12 | 16 |
|
13 | 17 | runs-on: ubuntu-24.04 |
14 | 18 |
|
| 19 | + permissions: |
| 20 | + contents: read |
| 21 | + packages: write |
| 22 | + attestations: write |
| 23 | + id-token: write |
| 24 | + |
15 | 25 | steps: |
16 | 26 | - name: Remove unnecessary files |
17 | 27 | run: | |
18 | 28 | sudo rm -rf /usr/share/dotnet |
19 | 29 | sudo rm -rf "$AGENT_TOOLSDIRECTORY" |
20 | | - - uses: actions/checkout@v4 |
21 | | - - name: Build the Docker image |
22 | | - run: docker build . --file Dockerfile --tag hdr-image:$(date +%s) |
| 30 | + - name: Checkout repository |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + - name: Log in to the Container registry |
| 34 | + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 |
| 35 | + with: |
| 36 | + registry: ${{ env.REGISTRY }} |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Extract metadata (tags, labels) for Docker |
| 41 | + id: meta |
| 42 | + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 |
| 43 | + with: |
| 44 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 45 | + |
| 46 | + - name: Build and push Docker image |
| 47 | + id: push |
| 48 | + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 |
| 49 | + with: |
| 50 | + context: . |
| 51 | + push: false |
| 52 | + tags: ${{ steps.meta.outputs.tags }} |
| 53 | + labels: ${{ steps.meta.outputs.labels }} |
| 54 | + |
| 55 | + - name: Generate artifact attestation |
| 56 | + uses: actions/attest-build-provenance@v2 |
| 57 | + with: |
| 58 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} |
| 59 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 60 | + push-to-registry: false |
| 61 | + |
| 62 | + # - name: Build the Docker image |
| 63 | + # run: docker build . --file Dockerfile --tag hdr-image:$(date +%s) |
0 commit comments