Skip to content

Commit

Permalink
ops: improve ci by attesting build
Browse files Browse the repository at this point in the history
  • Loading branch information
drawbu committed Oct 17, 2024
1 parent 07f8cb3 commit f1a2662
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ on:
branches:
- main

permissions:
contents: read
id-token: write

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

jobs:
docker:
runs-on: ubuntu-latest
Expand All @@ -14,18 +22,28 @@ jobs:
uses: actions/checkout@v4

- name: Setup Nix
uses: cachix/install-nix-action@v27
uses: cachix/install-nix-action@v30

- name: Build Docker image
run: nix build .#docker

- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Load Docker image
- name: Push Docker image to GitHub Container Registry
run: |
docker load < result
docker tag drawbu.dev ghcr.io/${{ github.repository }}:latest
- name: Push Docker image to GitHub Container Registry
run: docker push ghcr.io/${{ github.repository }}:latest
docker tag drawbu.dev ${{ env.IMAGE_NAME }}
docker push ${{ env.IMAGE_NAME }}
- name: Attest
uses: actions/attest-build-provenance@v1
id: attest
with:
subject-name: ${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

0 comments on commit f1a2662

Please sign in to comment.