Skip to content

ops: improve ci by attesting build #48

ops: improve ci by attesting build

ops: improve ci by attesting build #48

Workflow file for this run

name: Build Docker Image
on:
push:
branches:
- main
permissions:
contents: read
packages: write
id-token: write
attestations: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/${{ github.repository }}
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Nix
uses: cachix/install-nix-action@v30
- name: Build Docker image
run: nix build .#docker
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image to GitHub Container Registry
id: push
run: |
docker load < result
docker tag drawbu.dev ${{ env.IMAGE_NAME }}
docker push ${{ env.IMAGE_NAME }}
digest=$(docker image inspect ${{ env.IMAGE_NAME }} \
| nix run nixpkgs#jq -- --raw-output '.[].RepoDigests[]' \
| cut -d@ -f2)
echo "digest=$digest" >> "$GITHUB_OUTPUT"
- 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