forked from ossf/scorecard
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build + publish + SLSA workflow for attestor
Signed-off-by: Raghav Kaul <[email protected]>
- Loading branch information
1 parent
443c328
commit 1dc5a2e
Showing
1 changed file
with
67 additions
and
0 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,67 @@ | ||
on: | ||
push: | ||
tags: | ||
- "*" # triggers only if push new tag version, like `0.8.4` | ||
|
||
env: | ||
IMAGE_REGISTRY: "us-east4-docker.pkg.dev/openssf/" | ||
IMAGE_NAME: "scorecard-attestor" | ||
|
||
jobs: | ||
build: | ||
permissions: | ||
contents: read | ||
outputs: | ||
image: ${{ steps.image.outputs.image }} | ||
digest: ${{ steps.build.outputs.digest }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v2.3.4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@dc7b9719a96d48369863986a06765841d7ea23f6 # v2.0.0 | ||
|
||
- name: Authenticate Docker | ||
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b # v2.0.0 | ||
with: | ||
registry: ${{ env.IMAGE_REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} # FIXME - need GCB token stuff | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a # v4.0.1 | ||
with: | ||
images: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@e551b19e49efd4e98792db7592c17c09b89db8d8 # v3.0.0 | ||
id: build | ||
with: | ||
context: . | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
push: true | ||
|
||
- name: Output image | ||
id: image | ||
run: | | ||
# NOTE: Set the image as an output because the `env` context is not | ||
# available to the inputs of a reusable workflow call. | ||
image_name="${IMAGE_REGISTRY}/${IMAGE_NAME}" | ||
echo "image=$image_name" >> "$GITHUB_OUTPUT" | ||
provenance: | ||
needs: [build] | ||
permissions: | ||
actions: read # for detecting the Github Actions environment. | ||
id-token: write # for creating OIDC tokens for signing. | ||
packages: write # for uploading attestations. | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
image: ${{ needs.build.outputs.image }} | ||
digest: ${{ needs.build.outputs.digest }} | ||
registry-username: ${{ github.actor }} | ||
secrets: | ||
registry-password: ${{ secrets.GITHUB_TOKEN }} |