-
Notifications
You must be signed in to change notification settings - Fork 1
60 lines (51 loc) · 1.84 KB
/
ghcr-publish.yml
File metadata and controls
60 lines (51 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Attest Image (GH Container Registry)
on:
workflow_dispatch:
jobs:
build-artifact-ghcr:
name: Build/Attest Artifact (GHCR)
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Build artifact
run: date > artifact.bin
- name: Build Dockerfile
run: |
cat <<EOF > Dockerfile
FROM scratch
COPY artifact.bin .
EOF
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to GHCR
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: build-and-push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
platforms: 'linux/amd64,linux/arm64'
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Attest artifact
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build-and-push.outputs.digest }}
push-to-registry: true
- name: Verify OCI image
env:
GH_TOKEN: ${{ github.token }}
run: gh attestation verify oci://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest --owner "$GITHUB_REPOSITORY_OWNER"