Skip to content

Commit

Permalink
change action to follow gh docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobru committed May 27, 2024
1 parent f48c218 commit 606145c
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions .github/workflows/build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ on:
- contactform/**/*
- .github/workflows/build-push.yaml

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -28,10 +32,16 @@ jobs:
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Cache Docker layers
uses: actions/cache@v4
with:
Expand All @@ -40,12 +50,20 @@ jobs:
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
- name: Build and Push Docker image
id: push
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ./Dockerfile
tags: ghcr.io/vshn/conferenceli:latest
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
push: true

- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit 606145c

Please sign in to comment.