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 40b924d
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
branches:
- main

permissions:
contents: read
pages: write
id-token: write


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

jobs:
docker:
runs-on: ubuntu-latest
Expand All @@ -14,18 +24,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 40b924d

Please sign in to comment.