@@ -3,21 +3,6 @@ name: Reusable release workflow
3
3
on :
4
4
workflow_call :
5
5
inputs :
6
- registry :
7
- description : ' Registry'
8
- type : string
9
- required : false
10
- default : ghcr.io
11
- registry-username :
12
- description : ' Registry username'
13
- type : string
14
- required : false
15
- default : ${{ github.actor }}
16
- registry-password :
17
- description : ' Registry password'
18
- type : string
19
- required : false
20
- default : ' '
21
6
image :
22
7
description : ' Image name'
23
8
type : string
@@ -70,17 +55,27 @@ jobs:
70
55
steps :
71
56
-
uses :
imjasonh/[email protected]
72
57
- uses : sigstore/cosign-installer@v3
73
-
74
58
- name : Checkout
75
59
uses : actions/checkout@v4
76
60
77
- - name : Login to Registry
61
+ - name : Set Vars
62
+ id : vars
63
+ shell : bash
64
+ run : |
65
+ if [[ "${{ github.ref_name }}" == "main" ]]; then
66
+ echo "registry=ghcr.io" >> $GITHUB_OUTPUT
67
+ else
68
+ echo "registry=ttl.sh" >> $GITHUB_OUTPUT
69
+ fi
70
+
71
+ - if : steps.vars.outputs.registry == 'ghcr.io'
72
+ name : Login to GitHub Registry
78
73
uses : docker/login-action@v3
79
74
id : login-to-registry
80
75
with :
81
- registry : ${{ inputs.registry }}
82
- username : ${{ inputs.registry-username }}
83
- password : ${{ inputs.registry-password || github.token }}
76
+ registry : ghcr.io
77
+ username : ${{ github.actor }}
78
+ password : ${{ github.token }}
84
79
85
80
- name : Create SBOM directory
86
81
id : output
@@ -93,22 +88,22 @@ jobs:
93
88
uses : distroless/actions/apko-publish@main
94
89
with :
95
90
config : ${{ inputs.config-dir }}/${{ inputs.target }}.yaml
96
- tag : ${{ inputs .registry }}/${{ inputs.image }}:${{ inputs.tag }}
91
+ tag : ${{ steps.vars.outputs .registry }}/${{ inputs.image }}:${{ inputs.tag }}
97
92
package-append : ${{ inputs.packages }}
98
93
archs : ${{ inputs.archs }}
99
94
sbom-path : ${{ github.workspace }}/sbom
100
95
101
96
- id : digest
102
97
shell : bash
103
98
run : |
104
- echo "digest=$(crane digest ${{ inputs .registry }}/${{ inputs.image }}:${{ inputs.tag }})" >> $GITHUB_OUTPUT
99
+ echo "digest=$(crane digest ${{ steps.vars.outputs .registry }}/${{ inputs.image }}:${{ inputs.tag }})" >> $GITHUB_OUTPUT
105
100
if [[ "${{ inputs.archs }}" == *"amd64"* ]]; then
106
- echo "digest-amd64=$(crane digest --platform=linux/amd64 ${{ inputs .registry }}/${{ inputs.image }}:${{ inputs.tag }})" >> $GITHUB_OUTPUT
101
+ echo "digest-amd64=$(crane digest --platform=linux/amd64 ${{ steps.vars.outputs .registry }}/${{ inputs.image }}:${{ inputs.tag }})" >> $GITHUB_OUTPUT
107
102
else
108
103
echo "digest-amd64=''" >> $GITHUB_OUTPUT
109
104
fi
110
105
if [[ "${{ inputs.archs }}" == *"arm64"* ]]; then
111
- echo "digest-arm64=$(crane digest --platform=linux/arm64 ${{ inputs .registry }}/${{ inputs.image }}:${{ inputs.tag }})" >> $GITHUB_OUTPUT
106
+ echo "digest-arm64=$(crane digest --platform=linux/arm64 ${{ steps.vars.outputs .registry }}/${{ inputs.image }}:${{ inputs.tag }})" >> $GITHUB_OUTPUT
112
107
else
113
108
echo "digest-arm64=''" >> $GITHUB_OUTPUT
114
109
fi
@@ -121,12 +116,13 @@ jobs:
121
116
cosign sign \
122
117
--recursive \
123
118
--oidc-provider=github-actions \
124
- ${{ inputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest }}
119
+ ${{ steps.vars.outputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest }}
125
120
126
- - name : Attest provenance
121
+ - if : steps.vars.outputs.registry == 'ghcr.io'
122
+ name : Attest provenance
127
123
uses : actions/attest-build-provenance@v2
128
124
with :
129
- subject-name : ${{ inputs .registry }}/${{ inputs.image }}
125
+ subject-name : ${{ steps.vars.outputs .registry }}/${{ inputs.image }}
130
126
subject-digest : ${{ steps.digest.outputs.digest }}
131
127
push-to-registry : true
132
128
@@ -139,7 +135,7 @@ jobs:
139
135
--type=spdxjson \
140
136
--predicate=${{ github.workspace }}/sbom/sbom-index.spdx.json \
141
137
--oidc-provider=github-actions \
142
- ${{ inputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest }}
138
+ ${{ steps.vars.outputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest }}
143
139
144
140
- if : steps.digest.outputs.digest-amd64 != ''
145
141
name : Attest amd64 SBOM
@@ -151,7 +147,7 @@ jobs:
151
147
--type=spdxjson \
152
148
--predicate=${{ github.workspace }}/sbom/sbom-x86_64.spdx.json \
153
149
--oidc-provider=github-actions \
154
- ${{ inputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest-amd64 }}
150
+ ${{ steps.vars.outputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest-amd64 }}
155
151
156
152
- if : steps.digest.outputs.digest-arm64 != ''
157
153
name : Attest arm64 SBOM
@@ -163,14 +159,14 @@ jobs:
163
159
--type=spdxjson \
164
160
--predicate=${{ github.workspace }}/sbom/sbom-aarch64.spdx.json \
165
161
--oidc-provider=github-actions \
166
- ${{ inputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest-arm64 }}
162
+ ${{ steps.vars.outputs .registry }}/${{ inputs.image }}@${{ steps.digest.outputs.digest-arm64 }}
167
163
168
164
- if : inputs.scan == 'true'
169
165
name : Scan image
170
166
id : scan
171
167
uses : anchore/scan-action@v6
172
168
with :
173
- image : ${{ inputs .registry }}/${{ inputs.image }}:${{ inputs.tag }}
169
+ image : ${{ steps.vars.outputs .registry }}/${{ inputs.image }}:${{ inputs.tag }}
174
170
cache-db : true
175
171
fail-build : ' false'
176
172
severity-cutoff : ' high'
0 commit comments