Skip to content

Commit

Permalink
Add GHCR login step to allow signing
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-dufour committed May 28, 2024
1 parent 9dc0f5a commit 46e301b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Push to GHCR
name: Build image
on:
push:
workflow_dispatch:
Expand All @@ -7,12 +7,13 @@ on:
env:
IMAGE_NAME: ${{ github.event.repository.name }}
IMAGE_TAGS: latest ${{ github.sha }}
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY: ghcr.io
IMAGE_REGISTRY: ${{env.REGISTRY}}/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}

jobs:
push-ghcr:
build-push:
name: Build and push image
runs-on: ubuntu-22.04
strategy:
Expand Down Expand Up @@ -56,6 +57,14 @@ jobs:
extra-args: |
--disable-content-trust
# Login to GHCR to sign the image
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}

- name: Sign image with a key
run: |
cosign sign --yes --key env://COSIGN_PRIVATE_KEY ${{ env.IMAGE_REGISTRY }}/${{ steps.build_image.outputs.image }}@${DIGEST}
Expand Down

0 comments on commit 46e301b

Please sign in to comment.