Skip to content

Commit fcf6852

Browse files
authored
Update cosign action (#20)
* Replace sigstore action for cosign with a script * Add test for cosign * Update test
1 parent 0fb84dd commit fcf6852

2 files changed

Lines changed: 51 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,22 @@ jobs:
1414
markup-lint:
1515
name: Markup
1616
uses: ./.github/workflows/reusable-markup-lint.yml
17+
18+
validate-cosign:
19+
name: Validate / Cosign
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Clone repository
23+
uses: actions/checkout@v6
24+
- name: Pull Alpine image
25+
run: docker pull ghcr.io/linuxcontainers/alpine:latest
26+
- name: Cosign Alpine image (read-only)
27+
uses: ./actions/cosign/sign
28+
with:
29+
image-name: 'alpine'
30+
image-path: 'ghcr.io/linuxcontainers'
31+
image-tag: 'latest'
32+
readonly: 'true'
33+
permissions:
34+
id-token: write
35+
contents: read

actions/cosign/sign/action.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ description: |
88
```
99
1010
inputs:
11+
cosign-version:
12+
description: Version of cosign (check latest from https://github.com/sigstore/cosign/releases)
13+
required: false
14+
default: 'v3.0.6'
1115
image-name:
1216
description: Image name
1317
required: true
@@ -17,21 +21,46 @@ inputs:
1721
image-tag:
1822
description: Image tag
1923
required: true
24+
readonly:
25+
description: If true, skip the signing step
26+
required: false
27+
default: 'false'
2028

2129
runs:
2230
using: "composite"
2331
steps:
2432
- name: Install Cosign
25-
uses: sigstore/cosign-installer@v4.0.0
26-
with:
27-
cosign-release: 'v3.0.3'
33+
run: |
34+
echo "Downloading Cosign binary and checksums..."
35+
curl -sL -O https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/${COSIGN_BINARY}
36+
curl -sL -O "https://github.com/sigstore/cosign/releases/download/${COSIGN_VERSION}/${COSIGN_CHECKSUM_FILE}"
37+
38+
echo "Verifying checksum..."
39+
grep "${COSIGN_BINARY}$" "${COSIGN_CHECKSUM_FILE}" | sha256sum --check --status
40+
41+
if [ $? -eq 0 ]; then
42+
echo "Verification successful!"
43+
rm $COSIGN_CHECKSUM_FILE
44+
chmod +x $COSIGN_BINARY
45+
sudo mv $COSIGN_BINARY /usr/local/bin/cosign
46+
cosign version
47+
else
48+
echo "ERROR: Checksum verification failed!" >&2
49+
exit 1
50+
fi
51+
shell: bash
52+
env:
53+
COSIGN_BINARY: cosign-linux-amd64
54+
COSIGN_CHECKSUM_FILE: cosign_checksums.txt
55+
COSIGN_VERSION: ${{ inputs.cosign-version }}
2856
- name: Get image digest
2957
id: digest
3058
run: |
3159
DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ${{ inputs.image-path }}/${{ inputs.image-name }}:${{ inputs.image-tag }} | cut -d'@' -f2)
3260
echo "DIGEST=$DIGEST" >> $GITHUB_OUTPUT
3361
shell: bash
3462
- name: Sign image with Cosign
63+
if: inputs.readonly != 'true'
3564
env:
3665
COSIGN_EXPERIMENTAL: 1
3766
run: |

0 commit comments

Comments
 (0)