-
Notifications
You must be signed in to change notification settings - Fork 84
188 lines (165 loc) · 6.6 KB
/
cd.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
name: Continuous Delivery
on:
push:
branches:
- master
env:
# TODO create bot account
FORK_USER: etsauer
jobs:
setup:
runs-on: ubuntu-latest
outputs:
version_change: ${{ steps.variables.outputs.version_change }}
is_release: ${{ steps.variables.outputs.is_release }}
tags: ${{ steps.variables.outputs.tags }}
version: ${{ steps.variables.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
version_change:
- 'exporters/**'
- 'charts/**'
- 'pelorus-operator/**'
- uses: actions/upload-artifact@v3
with:
name: operator-code
path: pelorus-operator/bundle
- name: Store variables
id: variables
run: |
echo version_change=${{ steps.changes.outputs.version_change }} >> "$GITHUB_OUTPUT"
if [[ ${{ steps.changes.outputs.version_change }} == "true" ]];then
export CURRENT_CHART_VERSION="$(grep '^version: ' charts/pelorus/Chart.yaml | cut -c 10-)"
if [[ $CURRENT_CHART_VERSION == *"rc"* ]];then
echo "tags=$(echo latest,${{ github.sha }},v$CURRENT_CHART_VERSION)" >> "$GITHUB_OUTPUT"
echo is_release=false >> "$GITHUB_OUTPUT"
else
echo "tags=$(echo stable,latest,${{ github.sha }},v$CURRENT_CHART_VERSION)" >> "$GITHUB_OUTPUT"
echo is_release=true >> "$GITHUB_OUTPUT"
export CURRENT_OPERATOR_VERSION="$(grep "^VERSION ?= " pelorus-operator/Makefile | cut -c 12-)"
echo version=$CURRENT_OPERATOR_VERSION >> "$GITHUB_OUTPUT"
fi
else
echo is_release=false >> "$GITHUB_OUTPUT"
fi
release_drafter:
runs-on: ubuntu-latest
if: needs.setup.outputs.is_release == 'false'
needs: setup
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-push-exporters-images:
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.setup.outputs.version_change) }}
needs: setup
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build and push committime exporter
uses: "./.github/workflow_templates/build_push_exporters"
with:
image: 'pelorus-committime-exporter'
tags: ${{ needs.setup.outputs.tags }}
quay_imagenamespace: ${{ secrets.QUAY_IMAGE_NAMESPACE }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push deploytime exporter
uses: "./.github/workflow_templates/build_push_exporters"
with:
image: 'pelorus-deploytime-exporter'
tags: ${{ needs.setup.outputs.tags }}
quay_imagenamespace: ${{ secrets.QUAY_IMAGE_NAMESPACE }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push failure exporter
uses: "./.github/workflow_templates/build_push_exporters"
with:
image: 'pelorus-failure-exporter'
tags: ${{ needs.setup.outputs.tags }}
quay_imagenamespace: ${{ secrets.QUAY_IMAGE_NAMESPACE }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push releasetime exporter
uses: "./.github/workflow_templates/build_push_exporters"
with:
image: 'pelorus-releasetime-exporter'
tags: ${{ needs.setup.outputs.tags }}
quay_imagenamespace: ${{ secrets.QUAY_IMAGE_NAMESPACE }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
- name: Build and push webhook exporter
uses: "./.github/workflow_templates/build_push_exporters"
with:
image: 'pelorus-webhook-exporter'
tags: ${{ needs.setup.outputs.tags }}
quay_imagenamespace: ${{ secrets.QUAY_IMAGE_NAMESPACE }}
quay_username: ${{ secrets.QUAY_USERNAME }}
quay_password: ${{ secrets.QUAY_PASSWORD }}
build-and-push-operator-images:
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.setup.outputs.is_release) }}
needs: setup
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Quay.io
uses: redhat-actions/podman-login@v1
with:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
registry: quay.io
- name: Build and push operator image
working-directory: ./pelorus-operator
run: |
make podman-build
make podman-push
- name: Build and push operator bundle image
working-directory: ./pelorus-operator
run: |
make bundle-build
make bundle-push
create-pr-in-community-operators-prod:
runs-on: ubuntu-latest
if: ${{ fromJSON(needs.setup.outputs.is_release) }}
needs: [setup, build-and-push-operator-images]
steps:
- name: Checkout marketplace code
uses: actions/checkout@v4
with:
repository: ${{ env.FORK_USER }}/community-operators-prod
token: ${{ secrets.FORK_USER_TOKEN }}
- name: Update fork repo
run: |
git remote add upstream https://github.com/redhat-openshift-ecosystem/community-operators-prod.git
git fetch upstream
git rebase upstream/main
git push origin main
- name: Create branch
run: |
git checkout -b pelorus-operator-${{ needs.setup.outputs.version }}
mkdir -p operators/pelorus-operator/${{ needs.setup.outputs.version }}
- name: Download operator code
uses: actions/download-artifact@v3
with:
name: operator-code
path: operators/pelorus-operator/${{ needs.setup.outputs.version }}
- name: Push branch
run: |
git config user.name github-actions # TODO create bot account
git config user.email [email protected] # TODO create bot account
git add -A
git commit --signoff -m "operator pelorus-operator (${{ needs.setup.outputs.version }})"
git push origin pelorus-operator-${{ needs.setup.outputs.version }}
- name: Create PR
uses: "dora-metrics/pelorus/.github/workflow_templates/create-market-place-pr@master"
with:
token: ${{ secrets.FORK_USER_TOKEN }}
version: ${{ needs.setup.outputs.version }}
fork_user: ${{ env.FORK_USER }}