Skip to content

Commit 4eb17a4

Browse files
Refactor GitHub Actions workflow to build and sign images
1 parent 909987d commit 4eb17a4

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

‎.github/workflows/docker-ghcr.yml‎

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,80 @@ env:
1717
IMAGE_NAME: grandnode/grandnode2
1818

1919
jobs:
20-
build-and-push:
20+
build-and-sign:
21+
name: Build, Sign and Verify
2122
runs-on: ubuntu-latest
2223

2324
steps:
25+
# ---------------------------------------------------------
26+
# 1. Checkout
27+
# ---------------------------------------------------------
2428
- name: Checkout
2529
uses: actions/checkout@v5
2630

31+
# ---------------------------------------------------------
32+
# 2. Login to GitHub Container Registry
33+
# ---------------------------------------------------------
2734
- name: Login to GHCR
2835
uses: docker/login-action@v3
2936
with:
3037
registry: ${{ env.REGISTRY }}
3138
username: ${{ github.actor }}
3239
password: ${{ secrets.GITHUB_TOKEN }}
3340

41+
# ---------------------------------------------------------
42+
# 3. Build and push Docker image
43+
# ---------------------------------------------------------
3444
- name: Build and push Docker image
3545
id: build
3646
uses: docker/build-push-action@v6
3747
with:
3848
context: .
3949
push: true
50+
4051
tags: |
4152
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:test-ghcr
53+
4254
labels: |
4355
org.opencontainers.image.source=https://github.com/grandnode/grandnode2
4456
org.opencontainers.image.description=GrandNode GHCR private image test
4557
58+
# ---------------------------------------------------------
59+
# 4. Install Cosign
60+
# ---------------------------------------------------------
4661
- name: Install Cosign
4762
uses: sigstore/cosign-installer@v4.0.0
4863

49-
- name: Sign Docker image
64+
# ---------------------------------------------------------
65+
# 5. Show image digest
66+
# ---------------------------------------------------------
67+
- name: Show image digest
68+
run: |
69+
echo "Image:"
70+
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
71+
72+
echo "Digest:"
73+
echo "${{ steps.build.outputs.digest }}"
74+
75+
# ---------------------------------------------------------
76+
# 6. Keyless sign
77+
# ---------------------------------------------------------
78+
- name: Cosign keyless sign
5079
env:
5180
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5281
DIGEST: ${{ steps.build.outputs.digest }}
5382
run: |
5483
cosign sign --yes "${IMAGE}@${DIGEST}"
84+
85+
# ---------------------------------------------------------
86+
# 7. Keyless verify
87+
# ---------------------------------------------------------
88+
- name: Cosign keyless verify
89+
env:
90+
IMAGE: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
91+
DIGEST: ${{ steps.build.outputs.digest }}
92+
run: |
93+
cosign verify \
94+
"${IMAGE}@${DIGEST}" \
95+
--certificate-identity="https://github.com/grandnode/grandnode2/.github/workflows/docker-ghcr-test.yml@refs/heads/test/ghcr-private" \
96+
--certificate-oidc-issuer="https://token.actions.githubusercontent.com"

0 commit comments

Comments
 (0)