|
6 | 6 | tags: |
7 | 7 | - '*' |
8 | 8 |
|
| 9 | + |
9 | 10 | jobs: |
10 | 11 | goreleaser: |
11 | 12 | runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: read |
| 15 | + packages: write |
| 16 | + # This is used to complete the identity challenge |
| 17 | + # with sigstore/fulcio when running outside of PRs. |
| 18 | + id-token: write |
12 | 19 | steps: |
13 | 20 | - name: Checkout |
14 | 21 | uses: actions/checkout@v2 |
|
45 | 52 | TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" |
46 | 53 | fi |
47 | 54 | echo ::set-output name=version::${VERSION} |
| 55 | + echo ::set-output name=image::${DOCKER_IMAGE} |
48 | 56 | echo ::set-output name=tags::${TAGS} |
49 | 57 | echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') |
50 | 58 |
|
| 59 | + # Install the cosign tool except on PR |
| 60 | + # https://github.com/sigstore/cosign-installer |
| 61 | + - name: Install cosign |
| 62 | + if: github.event_name != 'pull_request' |
| 63 | + uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422 |
| 64 | + with: |
| 65 | + cosign-release: 'v1.4.0' |
| 66 | + |
51 | 67 | - name: Set up QEMU |
52 | 68 | uses: docker/setup-qemu-action@v1 |
53 | 69 |
|
|
61 | 77 | password: ${{ secrets.DOCKERHUB_TOKEN }} |
62 | 78 |
|
63 | 79 | - name: Build and push |
64 | | - id: docker_build |
| 80 | + id: build-and-push |
65 | 81 | uses: docker/build-push-action@v2 |
66 | 82 | with: |
67 | 83 | context: . |
|
77 | 93 | org.label-schema.url=${{ github.event.repository.html_url }} |
78 | 94 | org.label-schema.vcs-ref=${{ github.sha }} |
79 | 95 | org.label-schema.build-date=${{ steps.prep.outputs.created }} |
| 96 | +
|
| 97 | + # Sign the resulting Docker image digest except on PRs. |
| 98 | + # This will only write to the public Rekor transparency log when the Docker |
| 99 | + # repository is public to avoid leaking data. If you would like to publish |
| 100 | + # transparency data even for private images, pass --force to cosign below. |
| 101 | + # https://github.com/sigstore/cosign |
| 102 | + - name: Sign the published Docker image |
| 103 | + if: ${{ github.event_name != 'pull_request' }} |
| 104 | + env: |
| 105 | + COSIGN_EXPERIMENTAL: "true" |
| 106 | + # This step uses the identity token to provision an ephemeral certificate |
| 107 | + # against the sigstore community Fulcio instance. |
| 108 | + run: cosign sign ${{ steps.prep.outputs.image }}@${{ steps.build-and-push.outputs.digest }} |
0 commit comments