Created
March 11, 2022 12:15
-
-
Save embano1/da9f8dca57a96a42b607b1994ae6e595 to your computer and use it in GitHub Desktop.
Github Actions ko cosign Example
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
name: image | |
on: | |
push: | |
branches: ['main'] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
jobs: | |
image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v1 | |
with: | |
go-version: 1.17.x | |
- uses: sigstore/[email protected] | |
# Build ko from HEAD, build and push an image tagged with the commit SHA, | |
# then keylessly sign it with cosign. | |
- name: Publish and sign image | |
env: | |
KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | |
COSIGN_EXPERIMENTAL: 'true' | |
run: | | |
go build ./ | |
echo "${{ github.token }}" | ./ko login ghcr.io --username "${{ github.actor }}" --password-stdin | |
img=$(./ko build --bare --platform=all -t latest -t ${{ github.sha }} ./) | |
echo "built ${img}" | |
cosign sign ${img} \ | |
-a sha=${{ github.sha }} \ | |
-a run_id=${{ github.run_id }} \ | |
-a run_attempt=${{ github.run_attempt }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://github.com/google/ko/blob/5fb6c8cf84e968bd70821fd062d0c822021e3ccf/.github/workflows/image.yaml#L25