Skip to content

Commit 9fe0d6b

Browse files
committed
ops: improve ci by attesting build
1 parent 07f8cb3 commit 9fe0d6b

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

.github/workflows/docker.yml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
packages: write
11+
id-token: write
12+
13+
14+
env:
15+
REGISTRY: ghcr.io
16+
IMAGE_NAME: ghcr.io/${{ github.repository }}
17+
818
jobs:
919
docker:
1020
runs-on: ubuntu-latest
@@ -14,18 +24,28 @@ jobs:
1424
uses: actions/checkout@v4
1525

1626
- name: Setup Nix
17-
uses: cachix/install-nix-action@v27
27+
uses: cachix/install-nix-action@v30
1828

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

22-
- name: Log in to GitHub Container Registry
23-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
32+
- name: Login to GitHub Container Registry
33+
uses: docker/login-action@v3
34+
with:
35+
registry: ${{ env.REGISTRY }}
36+
username: ${{ github.actor }}
37+
password: ${{ secrets.GITHUB_TOKEN }}
2438

25-
- name: Load Docker image
39+
- name: Push Docker image to GitHub Container Registry
2640
run: |
2741
docker load < result
28-
docker tag drawbu.dev ghcr.io/${{ github.repository }}:latest
29-
30-
- name: Push Docker image to GitHub Container Registry
31-
run: docker push ghcr.io/${{ github.repository }}:latest
42+
docker tag drawbu.dev ${{ env.IMAGE_NAME }}
43+
docker push ${{ env.IMAGE_NAME }}
44+
45+
- name: Attest
46+
uses: actions/attest-build-provenance@v1
47+
id: attest
48+
with:
49+
subject-name: ${{ env.IMAGE_NAME }}
50+
subject-digest: ${{ steps.push.outputs.digest }}
51+
push-to-registry: true

0 commit comments

Comments
 (0)