Merge pull request #1404 from ko-build/dependabot/go_modules/github.c… #545
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 | |
with: | |
go-version-file: 'go.mod' | |
check-latest: true | |
- uses: sigstore/cosign-installer@4959ce089c160fddf62f7b42464195ba1a56d382 # v3.6.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 }} | |
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 }} |