Skip to content

Commit cdfb32c

Browse files
authored
feat: add image and chart signing (#535)
Signed-off-by: Bence Csati <[email protected]>
1 parent 12909c4 commit cdfb32c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.github/workflows/artifacts.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ jobs:
6666
- name: Set up Docker Buildx
6767
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1
6868

69+
- name: Set up Cosign
70+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
71+
6972
- name: Set image name
7073
id: image-name
7174
run: echo "value=ghcr.io/${{ github.repository }}" >> "$GITHUB_OUTPUT"
@@ -114,6 +117,19 @@ jobs:
114117
outputs: ${{ steps.build-output.outputs.value }}
115118
# push: ${{ inputs.publish }}
116119

120+
- name: Sign image with GitHub OIDC Token
121+
if: ${{ inputs.publish && github.repository_owner == 'bank-vaults' }} # Check if the workflow is called by the same GitHub organization
122+
env:
123+
DIGEST: ${{ steps.build.outputs.digest }}
124+
TAGS: ${{ steps.meta.outputs.tags }}
125+
run: |
126+
images=""
127+
for tag in ${TAGS}; do
128+
images+="${tag}@${DIGEST} "
129+
done
130+
131+
cosign sign --yes ${images}
132+
117133
- name: Set image ref
118134
id: image-ref
119135
run: echo "value=${{ steps.image-name.outputs.value }}@${{ steps.build.outputs.digest }}" >> "$GITHUB_OUTPUT"
@@ -186,6 +202,9 @@ jobs:
186202
with:
187203
version: v3.12.0
188204

205+
- name: Set up Cosign
206+
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 # v3.5.0
207+
189208
- name: Set chart name
190209
id: chart-name
191210
run: echo "value=${{ github.event.repository.name }}" >> "$GITHUB_OUTPUT"
@@ -221,6 +240,13 @@ jobs:
221240
helm package deploy/charts/${{ steps.chart-name.outputs.value }} --version ${{ steps.version.outputs.value }} --app-version ${{ steps.raw-version.outputs.value }}
222241
echo "package=${{ steps.chart-name.outputs.value }}-${{ steps.version.outputs.value }}.tgz" >> "$GITHUB_OUTPUT"
223242
243+
- name: Sign chart with GitHub OIDC Token
244+
if: ${{ inputs.publish && github.repository_owner == 'bank-vaults' }} # Check if the workflow is called by the same GitHub organization
245+
env:
246+
PACKAGE: ${{ steps.build.outputs.package }}
247+
run: |
248+
cosign sign-blob --yes $PACKAGE
249+
224250
- name: Upload chart as artifact
225251
uses: actions/upload-artifact@89ef406dd8d7e03cfd12d9e0a4a378f454709029 # v4.3.5
226252
with:

0 commit comments

Comments
 (0)