diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 1ce740d..5d96e8b 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -4,34 +4,60 @@ on: push: branches: [ "main" ] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: build: runs-on: ubuntu-latest + permissions: contents: read packages: write + attestations: write + id-token: write + steps: - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to GitHub Container Registry + - name: Checkout Repo + uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push + + - name: Extract Metadata for Docker + id: meta + uses: docker/metadata-action + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + id: push uses: docker/build-push-action@v6 with: platforms: linux/amd64,linux/arm64 push: true build-args: | BUILDKIT_CONTEXT_KEEP_GIT_DIR=true - tags: | - ghcr.io/${{ github.repository_owner }}/blog-ahmza-com:latest - ghcr.io/${{ github.repository_owner }}/blog-ahmza-com:${{ github.ref_name}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + ##ghcr.io/${{ github.repository_owner }}/blog-ahmza-com:latest + ##ghcr.io/${{ github.repository_owner }}/blog-ahmza-com:${{ github.ref_name}} + + - name: Generate Artifact Attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMG_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true