diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d621c24..8c2c493 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -31,10 +31,11 @@ jobs: # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - # - name: Install Cosign - # uses: sigstore/cosign-installer@main - # - name: Check install! - # run: cosign version + - name: Install Cosign + uses: sigstore/cosign-installer@main + + - name: Check Cosign Version + run: cosign version - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -83,6 +84,15 @@ jobs: # build-args: use for overwrite ARG value inside Dockerfile build-args: | VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} + + # https://github.com/sigstore/cosign + - name: Sign the published Docker image + env: + COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }} + COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }} + run: | + echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign --key env://COSIGN_PRIVATE_KEY -a "repo=${{ github.repository }}" -a "workflow=#${{ github.run_number }}" {}@${{ steps.build-and-push.outputs.digest }} + - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@master @@ -94,17 +104,4 @@ jobs: - name: Upload Trivy scan results to GitHub Security tab uses: github/codeql-action/upload-sarif@v2 with: - sarif_file: "trivy-results.sarif" - - # Sign the resulting Docker image digest except on PRs. - # This will only write to the public Rekor transparency log when the Docker - # repository is public to avoid leaking data. If you would like to publish - # transparency data even for private images, pass --force to cosign below. - # https://github.com/sigstore/cosign - # - name: Sign the published Docker image - # if: ${{ github.event_name != 'pull_request' }} - # env: - # COSIGN_EXPERIMENTAL: "true" - # # This step uses the identity token to provision an ephemeral certificate - # # against the sigstore community Fulcio instance. - # run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign {}@${{ steps.build-and-push.outputs.digest }} \ No newline at end of file + sarif_file: "trivy-results.sarif" \ No newline at end of file