-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Batuhan Apaydın <[email protected]>
- Loading branch information
1 parent
b324861
commit 545f16b
Showing
4 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: image | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [created] | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: write | ||
|
||
jobs: | ||
image: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
commit-date: ${{ steps.ldflags.outputs.commit-date }} | ||
commit: ${{ steps.ldflags.outputs.commit }} | ||
version: ${{ steps.ldflags.outputs.version }} | ||
tree-state: ${{ steps.ldflags.outputs.tree-state }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19 | ||
check-latest: true | ||
- uses: sigstore/[email protected] | ||
- uses: ko-build/[email protected] | ||
- id: ldflags | ||
run: | | ||
echo "commit-date=$(git log --date=iso8601-strict -1 --pretty=%ct)" >> "$GITHUB_OUTPUT" | ||
echo "commit=$GITHUB_SHA" >> "$GITHUB_OUTPUT" | ||
echo "version=$(git describe --tags --always --dirty | cut -c2-)" >> "$GITHUB_OUTPUT" | ||
echo "tree-state=$(if git diff --quiet; then echo "clean"; else echo "dirty"; fi)" >> "$GITHUB_OUTPUT" | ||
- name: Publish and sign image | ||
env: | ||
KO_DOCKER_REPO: ghcr.io/${{ github.repository }} | ||
COSIGN_EXPERIMENTAL: 'true' | ||
run: | | ||
export LDGLAGS="-X main.Version=${{needs.args.outputs.version}} -X main.Commit=${{needs.args.outputs.commit}} -X main.CommitDate=${{needs.args.outputs.commit-date}} -X main.TreeState=${{needs.args.outputs.tree-state}}" | ||
echo "${{ github.token }}" | ko login ghcr.io --username "${{ github.actor }}" --password-stdin | ||
img=$(ko build --bare --platform=all -t latest -t ${{ github.sha }} ./cmd/sbom-scorecard) | ||
echo "built ${img}" | ||
cosign sign ${img} \ | ||
-a sha=${{ github.sha }} \ | ||
-a run_id=${{ github.run_id }} \ | ||
-a run_attempt=${{ github.run_attempt }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
baseImageOverride: cgr.dev/chainguard/static:latest | ||
|
||
builds: | ||
- id: sbom-scorecard | ||
ldflags: | ||
- "{{ .Env.LDFLAGS }}" |
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
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