-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Check that cosign.pub matches private key
This avoids images which can't be updated due to `invalid signature` errors because cosign.pub doesn't match the private key actually used for signing. The error is caught early in the build process as there's no point creating an image if cosign.pub is wrong.
- Loading branch information
Showing
1 changed file
with
24 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,32 @@ jobs: | |
- name: Checkout Push to Registry action | ||
uses: actions/checkout@v4 | ||
|
||
<<<<<<< HEAD | ||
- name: Check just syntax | ||
uses: ublue-os/just-action@v1 | ||
======= | ||
# Confirm that cosign.pub matches SIGNING_SECRET | ||
- uses: sigstore/[email protected] | ||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/live' | ||
|
||
- name: Check SIGNING_SECRET matches cosign.pub | ||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/live' | ||
env: | ||
COSIGN_EXPERIMENTAL: false | ||
COSIGN_PASSWORD: "" | ||
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }} | ||
shell: bash | ||
run: | | ||
echo "Checking for difference between public key from SIGNING_SECRET and cosign.pub" | ||
delta=$(diff -u <(cosign public-key --key env://COSIGN_PRIVATE_KEY) cosign.pub) | ||
if [ -z "$delta" ]; then | ||
echo "cosign.pub matches SIGNING_SECRET" | ||
else | ||
echo "cosign.pub does not match SIGNING_SECRET" | ||
echo "$delta" | ||
exit 1 | ||
fi | ||
>>>>>>> 8ce189c (feat: Check that cosign.pub matches private key) | ||
|
||
- name: Add yq (for reading recipe.yml) | ||
uses: mikefarah/[email protected] | ||
|
@@ -183,9 +207,6 @@ jobs: | |
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Sign container | ||
- uses: sigstore/[email protected] | ||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/live' | ||
|
||
- name: Sign container image | ||
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/live' | ||
run: | | ||
|