From 45077ad5e7f11861ceee8d3a96a8670fba1c8a34 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Thu, 18 Jul 2024 15:30:27 +0200 Subject: [PATCH] feat: add image and chart signing Signed-off-by: Bence Csati --- .github/workflows/artifacts.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 0e9040fb..b6e3ded3 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -66,6 +66,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 + - name: Set up Cosign + uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0 + - name: Set image name id: image-name run: echo "value=ghcr.io/${{ github.repository }}" >> "$GITHUB_OUTPUT" @@ -114,6 +117,19 @@ jobs: outputs: ${{ steps.build-output.outputs.value }} # push: ${{ inputs.publish }} + - name: Sign image with GitHub OIDC Token + if: ${{ inputs.publish && github.repository_owner == 'bank-vaults' }} # Check if the workflow is called by the same GitHub organization + env: + DIGEST: ${{ steps.build.outputs.digest }} + TAGS: ${{ steps.meta.outputs.tags }} + run: | + images="" + for tag in ${TAGS}; do + images+="${tag}@${DIGEST} " + done + + cosign sign --yes ${images} + - name: Set image ref id: image-ref run: echo "value=${{ steps.image-name.outputs.value }}@${{ steps.build.outputs.digest }}" >> "$GITHUB_OUTPUT" @@ -186,6 +202,9 @@ jobs: with: version: v3.12.0 + - name: Set up Cosign + uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0 + - name: Set chart name id: chart-name run: echo "value=${{ github.event.repository.name }}" >> "$GITHUB_OUTPUT" @@ -221,6 +240,13 @@ jobs: helm package deploy/charts/${{ steps.chart-name.outputs.value }} --version ${{ steps.version.outputs.value }} --app-version ${{ steps.raw-version.outputs.value }} echo "package=${{ steps.chart-name.outputs.value }}-${{ steps.version.outputs.value }}.tgz" >> "$GITHUB_OUTPUT" + - name: Sign chart with GitHub OIDC Token + if: ${{ inputs.publish && github.repository_owner == 'bank-vaults' }} # Check if the workflow is called by the same GitHub organization + env: + PACKAGE: ${{ steps.build.outputs.package }} + run: | + cosign sign-blob --yes $PACKAGE + - name: Upload chart as artifact uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: