-
Notifications
You must be signed in to change notification settings - Fork 10
59 lines (49 loc) · 1.39 KB
/
sign.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: sign
on:
workflow_call:
inputs:
image_digest:
description: 'Fully-qualified image digest to verify (registry/image@sha256:digest)'
required: true
type: string
cosign_version:
description: 'The version of cosign to use'
required: false
type: string
default: 'v2.0.1'
permissions:
contents: read
jobs:
sign:
runs-on: ubuntu-latest
permissions:
actions: read
packages: write
steps:
- name: Install Cosign
uses: sigstore/cosign-installer@9614fae9e5c5eddabb09f90a270fcb487c9f7149 # v3.3.0
with:
cosign-release: ${{ inputs.cosign_version }}
- name: Check Cosign
run: |
cosign version
- name: Auth Cosign
run: |
cosign login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- name: Generate Keys
run: |
COSIGN_PASSWORD=$(openssl rand -base64 12)
cosign generate-key-pair
- name: Sign Image
env:
COSIGN_YES: true
run: |
cosign sign ${{ inputs.image_digest }} \
--key cosign.key \
-a sha=${{ github.sha }} \
-a run_id=${{ github.run_id }} \
-a run_attempt=${{ github.run_attempt }} \
-a tag=${{ env.GITHUB_REF_NAME }}
- name: Verify Signature
run: |
cosign verify --key cosign.pub ${{ inputs.image_digest }}