176 lines (160 loc) · 6.52 KB
/
build-and-publish.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
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
---
name: Build and Publish Images
on:
push:
branches:
- redhat-3.5
- use-bundle
jobs:
quay-image:
name: Calculate Quay Image Digest
runs-on: 'ubuntu-latest'
outputs:
digest: ${{ steps.set-output.outputs.digest }}
env:
IMAGE_REGISTRY: quay.io/fmissi
TAG: 3.5
steps:
- name: Pull Image
id: pull-image
run: docker pull "${IMAGE_REGISTRY}"/quay:"${TAG}"
- name: Set Output
id: set-output
run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/quay:${TAG})"
clair-image:
name: Calculate Clair Image Digest
runs-on: 'ubuntu-latest'
outputs:
digest: ${{ steps.set-output.outputs.digest }}
env:
IMAGE_REGISTRY: quay.io/fmissi
TAG: 3.5
steps:
- name: Pull Image
id: pull-image
run: docker pull "${IMAGE_REGISTRY}"/clair:"${TAG}"
- name: Set Output
id: set-output
run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/clair:${TAG})"
builder-image:
name: Calculate Builder Image Digest
runs-on: 'ubuntu-latest'
outputs:
digest: ${{ steps.set-output.outputs.digest }}
env:
IMAGE_REGISTRY: quay.io/fmissi
TAG: 3.5
steps:
- name: Pull Image
id: pull-image
run: docker pull "${IMAGE_REGISTRY}"/quay-builder:"${TAG}"
- name: Set Output
id: set-output
run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/quay-builder:${TAG})"
qemu-builder-image:
name: Calculate Qemu Builder Image Digest
runs-on: 'ubuntu-latest'
outputs:
digest: ${{ steps.set-output.outputs.digest }}
env:
IMAGE_REGISTRY: quay.io/fmissi
steps:
- name: Pull Image
id: pull-image
run: docker pull "${IMAGE_REGISTRY}"/quay-builder-qemu:latest
- name: Set Output
id: set-output
run: echo "::set-output name=digest::$(docker inspect --format='{{index .RepoDigests 0}}' ${IMAGE_REGISTRY}/quay-builder-qemu:latest)"
commit-sha:
name: Get Current Commit Sha
runs-on: 'ubuntu-latest'
outputs:
sha_short: ${{ steps.set-output.outputs.sha_short }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Set Output
id: set-output
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
operator-image:
name: Publish Operator Image
needs: commit-sha
runs-on: 'ubuntu-latest'
env:
OPERATOR_TAG: 3.5-${{ needs.commit-sha.outputs.sha_short }}
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: quay.io/fmissi/quay-operator:${{ env.OPERATOR_TAG }}
operator-index-images:
name: Publish Catalog Index Image
runs-on: 'ubuntu-latest'
needs: [quay-image, clair-image, builder-image, qemu-builder-image, operator-image, commit-sha]
env:
OPERATOR_NAME: quay-operator-test
BUNDLE: quay.io/fmissi/quay-operator-bundle
INDEX: quay.io/fmissi/quay-operator-index
TAG: 3.5
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Update CSV Image Versions
uses: mikefarah/yq@master
env:
OPERATOR_IMAGE: quay.io/fmissi/quay-operator:3.5-${{ needs.commit-sha.outputs.sha_short }}
with:
cmd: |
yq eval -i '
.metadata.name = strenv(OPERATOR_NAME) |
.metadata.annotations.quay-version = strenv(TAG) |
.metadata.annotations.containerImage = strenv(OPERATOR_IMAGE) |
.spec.version = strenv(TAG)+".999" |
del(.spec.replaces) |
.spec.install.spec.deployments[0].name = strenv(OPERATOR_NAME) |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].image = strenv(OPERATOR_IMAGE) |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[4].value = "${{needs.quay-image.outputs.digest}}" |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[5].value = "${{needs.clair-image.outputs.digest}}" |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[6].value = "${{needs.builder-image.outputs.digest}}" |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[7].value = "${{needs.qemu-builder-image.outputs.digest}}" |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[8].value = "centos/postgresql-10-centos7@sha256:de1560cb35e5ec643e7b3a772ebaac8e3a7a2a8e8271d9e91ff023539b4dfb33" |
.spec.install.spec.deployments[0].spec.template.spec.containers[0].env[9].value = "centos/redis-32-centos7@sha256:06dbb609484330ec6be6090109f1fa16e936afcf975d1cbc5fff3e6c7cae7542"
' bundle/downstream/manifests/quay-operator.clusterserviceversion.yaml
- name: Update Bundle Annotations
uses: mikefarah/yq@master
with:
cmd: |
yq eval -i '
.annotations."operators.operatorframework.io.bundle.channel.default.v1" = "test" |
.annotations."operators.operatorframework.io.bundle.channels.v1" = "test" |
.annotations."operators.operatorframework.io.bundle.package.v1" = strenv(OPERATOR_NAME)
' bundle/downstream/metadata/annotations.yaml
- name: Publish Bundle Image
run: |
docker build -t "${BUNDLE}:${TAG}" -f ./bundle/Dockerfile ./bundle/downstream
docker push "${BUNDLE}:${TAG}"
- name: Publish Catalog Index
env:
OPM_DOWNLOAD_URL: https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp/stable-4.6/
OPM_TAR: opm-linux.tar.gz
run: |
wget "${OPM_DOWNLOAD_URL}/${OPM_TAR}"
tar xvf "${OPM_TAR}"
./opm index add --build-tool docker --bundles "${BUNDLE}:${TAG}" --tag "${INDEX}:${TAG}"
docker push "${INDEX}:${TAG}"