Skip to content

Commit

Permalink
feat: Use Chainguard's cosign image instead of cosign-installer
Browse files Browse the repository at this point in the history
  • Loading branch information
EyeCantCU committed Jan 7, 2024
1 parent 11f8c11 commit a2c2e43
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
6 changes: 1 addition & 5 deletions sign/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,14 @@ runs:
username: ${{ github.actor }}
password: ${{ inputs.registry-token }}

- name: Install cosign
uses: sigstore/cosign-installer@v3.3.0

- name: Sign container image
shell: bash
run: |
REGISTRY=$(echo ${{ inputs.registry }} | awk '{print tolower($0)}')
for CONTAINER in $(echo "${CONTAINERS}" | tr "," "\n"); do
cosign sign -y --key env://COSIGN_PRIVATE_KEY $REGISTRY/${CONTAINER}@${TAGS}
podman run --env-host cgr.dev/chainguard/cosign sign -y --key env://COSIGN_PRIVATE_KEY $REGISTRY/${CONTAINER}@${TAGS}
done
env:
CONTAINERS: ${{ inputs.containers }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ inputs.signing-secret }}
TAGS: ${{ inputs.tags }}
5 changes: 5 additions & 0 deletions verify/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM cgr.dev/chainguard/cosign:latest

COPY verify.sh /tmp/verify.sh

ENTRYPOINT ["/tmp/verify.sh"]
43 changes: 9 additions & 34 deletions verify/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,12 @@ inputs:
default: 'ghcr.io/ublue-os'
required: true
runs:
using: "composite"
steps:
- name: Install cosign
uses: sigstore/cosign-installer@v3.3.0

- name: Verify container
shell: bash
run: |
REGISTRY=$(echo ${{ inputs.registry }} | awk '{print tolower($0)}')
set -o pipefail
if [[ -n "${{ inputs.cert-identity }}" && -n "${{ inputs.oidc-issuer }}" ]]; then
for CONTAINER in $(echo "${CONTAINERS}" | tr "," "\n"); do
if ! cosign verify $REGISTRY/${CONTAINER} --certificate-identity=${{ inputs.cert-identity }} --certificate-oidc-issuer=${{ inputs.oidc-issuer }} | jq; then
echo "NOTICE: Verification failed. Please ensure your public key is correct."
if [[ "${{ matrix.fail-silently }}" != 'true' ]]; then
exit 1
fi
fi
done
elif [[ -n "${{ inputs.pubkey }}" ]]; then
for CONTAINER in $(echo "${CONTAINERS}" | tr "," "\n"); do
if ! cosign verify --key ${{ inputs.pubkey }} $REGISTRY/${CONTAINER} | jq; then
echo "NOTICE: Verification failed. Please ensure your public key is correct."
if [[ "${{ matrix.fail-silently }}" != 'true' ]]; then
exit 1
fi
fi
done
else
exit 1
fi
env:
CONTAINERS: ${{ inputs.containers }}
COSIGN_EXPERIMENTAL: false
using: "docker"
image: "Dockerfile"
env:
CERT_IDENTITY: ${{ inputs.cert-identity }}
CONTAINERS: ${{ inputs.containers }}
FAIL_SILENTLY: ${{ inputs.fail-silently }}
PUBKEY: ${{ inputs.pubkey }}
OIDC_ISSUER: ${{ inputs.oidc-issuer }}
REGISTRY: ${{ inputs.registry }}
27 changes: 27 additions & 0 deletions verify/verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -ouex pipefail

REGISTRY=$(echo ${{ inputs.registry }} | awk '{print tolower($0)}')

if [[ -n "$CERT_IDENTITY" && -n "$OIDC_ISSUER" ]]; then
for CONTAINER in $(echo "${CONTAINERS}" | tr "," "\n"); do
if cosign verify $REGISTRY/${CONTAINER} --certificate-identity=$CERT_IDENTITY --certificate-oidc-issuer=$OIDC_ISSUER | jq; then
echo "NOTICE: Verification failed. Please ensure your public key is correct."
if [[ "$FAIL_SILENTLY" != 'true' ]]; then
exit 1
fi
fi
done
elif [[ -n "$PUBKEY" ]]; then
for CONTAINER in $(echo "${CONTAINERS}" | tr "," "\n"); do
if ! cosign verify --key $PUBKEY $REGISTRY/${CONTAINER} | jq; then
echo "NOTICE: Verification failed. Please ensure your public key is correct."
if [[ "$FAIL_SILENTLY" != 'true' ]]; then
exit 1
fi
fi
done
else
exit 1
fi

0 comments on commit a2c2e43

Please sign in to comment.