forked from openshift/oadp-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
307 lines (304 loc) · 14.9 KB
/
edge-catalog.yml
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: edge-catalog
on:
push:
branches: [edge]
paths:
- ".github/workflows/edge-catalog.yml"
- "appendMakefile"
schedule:
- cron: '30 1-22/3 * * *'
- cron: '0 0-21/3 * * *'
workflow_dispatch:
inputs:
branch:
default: oadp-1.1
description: The branch to build catalog for
type: string
required: true
watch:
types: [started]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
publish-new-edge-catalog:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' || github.event.inputs.branch != github.ref_name && github.event.inputs.branch != '' }}
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
env:
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_DISPATCH_INPUT_BRANCH: ${{ github.event.inputs.branch }}
steps:
- uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# In this step, this action saves a list of existing images,
# the cache is created without them in the post run.
# It also restores the cache if it exists.
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- uses: actions/checkout@v2
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
- name: checkout target branch
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
if: ${{ github.event_name != 'push' && github.event_name != 'schedule'}}
- name: Get upstream/oadp-1.1
run: |
git remote -vv
git remote add upstream https://github.com/openshift/oadp-operator.git
git fetch upstream
- name: Reset to upstream/oadp-1.1
run: |
git reset upstream/oadp-1.1
git add appendMakefile # preserve appendMakefile
git restore . # discard old changes
# appendMakefile
cat appendMakefile >> Makefile
echo "upstream/oadp-1.1" > /tmp/rev-parse-head
echo "${{ github.ref_name }}" > /tmp/tag
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
- name: appendMakefile to target branch and appendMakefile
run: |
curl https://raw.githubusercontent.com/kaovilai/oadp-operator/edge/Tiger_passant_guardant.svg > Tiger_passant_guardant.svg
curl https://raw.githubusercontent.com/kaovilai/oadp-operator/edge/appendMakefile >> Makefile
echo "HEAD" > /tmp/rev-parse-head
echo "${{ github.event.inputs.branch }}" > /tmp/tag
if: ${{ github.event_name != 'push' && github.event_name != 'schedule'}}
- run: cat Makefile
- name: get git ref
id: git-ref
run: echo "::set-output name=GIT_REF::$(git rev-parse $(cat /tmp/rev-parse-head))"
- name: echo git-ref
run: echo ${{ steps.git-ref.outputs.GIT_REF }}
- name: get build tag
id: build-tag
run: echo "::set-output name=BUILD_TAG::$(cat /tmp/tag)"
- name: echo build-tag
run: echo ${{ steps.build-tag.outputs.BUILD_TAG }}
- name: get year month date hour minutes
id: dateversion
run: echo "::set-output name=YMdHM::$(date -u +%Y%m%d%H%M)"
- name: echo dateversion
run: echo ${{ steps.dateversion.outputs.YMdHM }}
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- uses: actions/setup-go@v2
with:
go-version: '^1.16.6' # The Go version to download (if necessary) and use.
- run: go version
- name: install operator-sdk opm
run: |
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.18.1
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
chmod +x operator-sdk_${OS}_${ARCH} && sudo mv operator-sdk_${OS}_${ARCH} /usr/local/bin/operator-sdk
export OPM_DL_URL=https://github.com/operator-framework/operator-registry/releases/download/v1.21.0
curl -LO ${OPM_DL_URL}/${OS}-${ARCH}-opm
chmod +x ${OS}-${ARCH}-opm && sudo mv ${OS}-${ARCH}-opm /usr/local/bin/opm
- name: Install cosign
if: ${{ github.event_name != 'pull_request' }}
uses: sigstore/cosign-installer@main
with:
cosign-release: 'v1.12.0'
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
- name: Setup Docker buildx
id: buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: Log into registry ${{ env.REGISTRY }}
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: check ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.git-ref.outputs.GIT_REF }} can be pulled
id: catalog-git-ref-exist
continue-on-error: true
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.git-ref.outputs.GIT_REF }}
- name: check ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.build-tag.outputs.BUILD_TAG }} can be pulled
id: catalog-build-tag-exist
continue-on-error: true
run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.build-tag.outputs.BUILD_TAG }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta-git-ref
if: ${{ steps.catalog-git-ref-exist.outcome != 'success' }}
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.git-ref.outputs.GIT_REF }}
- name: Extract Docker metadata
id: meta-build-tag
if: ${{ steps.catalog-build-tag-exist.outcome != 'success' }}
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ steps.build-tag.outputs.BUILD_TAG }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push-git-ref
if: ${{ steps.catalog-git-ref-exist.outcome != 'success' }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-git-ref.outputs.tags }}
labels: ${{ steps.meta-git-ref.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push-build-tag
if: ${{ steps.catalog-build-tag-exist.outcome != 'success' }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-build-tag.outputs.tags }}
labels: ${{ steps.meta-build-tag.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' && steps.catalog-git-ref-exist.outcome != 'success' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push-git-ref.outputs.digest }}
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' && steps.catalog-build-tag-exist.outcome != 'success' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push-build-tag.outputs.digest }}
- name: make bundle
if: ${{ steps.catalog-git-ref-exist.outcome != 'success' }}
run: CHANNELS=${{ steps.build-tag.outputs.BUILD_TAG }},${{ steps.git-ref.outputs.GIT_REF }} VERSION=0.99.${{ steps.dateversion.outputs.YMdHM }} IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.build-and-push-git-ref.outputs.digest }} make replace-icon bundle
- name: Extract Docker metadata
id: meta-bundle-git-ref
if: ${{ steps.catalog-git-ref-exist.outcome != 'success' }}
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle
tags: |
type=raw,value=${{ steps.git-ref.outputs.GIT_REF }}
- name: Extract Docker metadata
id: meta-bundle-build-tag
if: ${{ steps.catalog-build-tag-exist.outcome != 'success' }}
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle
tags: |
type=raw,value=${{ steps.build-tag.outputs.BUILD_TAG }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push-bundle-git-ref
if: ${{ steps.catalog-git-ref-exist.outcome != 'success' }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
file: bundle.Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-bundle-git-ref.outputs.tags }}
labels: ${{ steps.meta-bundle-git-ref.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push-bundle-build-tag
if: ${{ steps.catalog-build-tag-exist.outcome != 'success' }}
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
file: bundle.Dockerfile
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta-bundle-build-tag.outputs.tags }}
labels: ${{ steps.meta-bundle-build-tag.outputs.labels }}
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' && steps.catalog-git-ref-exist.outcome != 'success' }}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle@${{ steps.build-and-push-bundle-git-ref.outputs.digest }}
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' && steps.catalog-build-tag-exist.outcome != 'success'}}
env:
COSIGN_EXPERIMENTAL: "true"
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: cosign sign ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle@${{ steps.build-and-push-bundle-build-tag.outputs.digest }}
- name: add bundle to git ref catalog build and push
if: ${{ steps.catalog-git-ref-exist.outcome != 'success' }}
run: |
CATALOG_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.git-ref.outputs.GIT_REF }} \
BUNDLE_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle:${{ steps.git-ref.outputs.GIT_REF }} \
make catalog-build catalog-push
- name: add bundle to ${{ steps.build-tag.outputs.BUILD_TAG }} existing catalog build and push
if: ${{ steps.catalog-build-tag-exist.outcome == 'success' }}
id: add-to-existing-catalog
continue-on-error: true
run: |
CATALOG_BASE_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.build-tag.outputs.BUILD_TAG }} \
CATALOG_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.build-tag.outputs.BUILD_TAG }} \
BUNDLE_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle:${{ steps.git-ref.outputs.GIT_REF }} \
make catalog-build-replaces catalog-push
- name: if existing fail, add bundle to new ${{ steps.build-tag.outputs.BUILD_TAG }} catalog build and push
if: ${{ steps.catalog-build-tag-exist.outcome != 'success'}}
run: |
CATALOG_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-catalog:${{ steps.build-tag.outputs.BUILD_TAG }} \
BUNDLE_IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-bundle:${{ steps.git-ref.outputs.GIT_REF }} \
make catalog-build-replaces catalog-push
- name: git add
run: git add .
- name: git status
run: git status
- name: git diff
run: git diff upstream/oadp-1.1