Skip to content

Commit

Permalink
Sign images with cosign
Browse files Browse the repository at this point in the history
  • Loading branch information
samhclark committed Sep 22, 2024
1 parent 064f5ea commit c37d499
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jobs:
# Checkout push-to-registry action GitHub repository
- name: Checkout Push to Registry action
uses: actions/checkout@v4

- name: Install cosign
if: ${{ github.event_name != 'pull_request' }}
uses: sigstore/[email protected]
with:
cosign-release: 'v2.4.0'

# Build image using Buildah action
- name: Build Image
Expand All @@ -34,6 +40,14 @@ jobs:
${{ github.sha }}
40
oci: false

- name: Log in to GitHub Container Registry
uses: redhat-actions/podman-login@v1
if: ${{ github.event_name != 'pull_request' }}
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io/${{ github.repository_owner }}

- name: Push To GHCR
uses: redhat-actions/push-to-registry@v2
Expand All @@ -48,13 +62,15 @@ jobs:
extra-args: |
--disable-content-trust
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Sign the published OCI image
if: ${{ github.event_name != 'pull_request' }}
env:
digest: ${{ steps.push.outputs.digest }}
fully_qualified_image_names_json: ${{ steps.push.outputs.registry-paths }}
run: >
echo "${fully_qualified_image_names_json}"
| jq -r '.[]'
| xargs -I {} cosign sign --yes "{}@${digest}"
- name: Echo outputs
if: github.event_name != 'pull_request'
Expand Down

0 comments on commit c37d499

Please sign in to comment.