Skip to content

Merge pull request #1319 from ko-build/dependabot/github_actions/gith… #506

Merge pull request #1319 from ko-build/dependabot/github_actions/gith…

Merge pull request #1319 from ko-build/dependabot/github_actions/gith… #506

Workflow file for this run

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@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version-file: 'go.mod'
check-latest: true
- uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
# 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} --yes \
-a sha=${{ github.sha }} \
-a run_id=${{ github.run_id }} \
-a run_attempt=${{ github.run_attempt }}