-
Notifications
You must be signed in to change notification settings - Fork 65
237 lines (220 loc) · 8.65 KB
/
deploy.yml
File metadata and controls
237 lines (220 loc) · 8.65 KB
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
---
name: Deployment
on: # yamllint disable-line rule:truthy
workflow_run:
workflows:
- Build and test
branches:
- main
types:
- completed
workflow_dispatch:
jobs:
prepare-env:
runs-on: ubuntu-latest
outputs:
short_sha: ${{ steps.prepare.outputs.short_sha }}
steps:
- id: prepare
run: |
echo "short_sha=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
configure-stage-cluster:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
needs:
- prepare-env
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
run: |
# Install python packages needed from ansible
pipx inject ansible-core jmespath openshift pygithub
- name: Configure stage cluster
uses: dawidd6/action-ansible-playbook@e8303e5fa5b52015d59fd5bc8c968943bd5f349c # v6
with:
playbook: playbooks/config-ocp-cluster.yml
directory: ./ansible
requirements: playbooks/requirements.yml
vault_password: ${{secrets.VAULT_PASSWORD}}
options: |
--inventory ./inventory/clusters
--extra-vars "clusters=stage-cluster"
--extra-vars "env=stage"
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
--verbose
deploy-dev:
runs-on: ubuntu-latest
needs:
- prepare-env
- configure-stage-cluster
environment:
name: dev
env:
SHORT_SHA: ${{needs.prepare-env.outputs.short_sha}}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
run: |
# Install python packages needed from ansible
pipx inject ansible-core jmespath openshift pygithub
- name: Deploy dev environment
uses: dawidd6/action-ansible-playbook@e8303e5fa5b52015d59fd5bc8c968943bd5f349c # v6
with:
playbook: playbooks/deploy.yml
directory: ./ansible
requirements: playbooks/requirements.yml
vault_password: ${{secrets.VAULT_PASSWORD}}
options: |
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
--extra-vars "env=dev"
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
--skip-tags ci,import-index-images
--verbose
deploy-qa:
runs-on: ubuntu-latest
needs:
- prepare-env
- configure-stage-cluster
environment:
name: qa
env:
SHORT_SHA: ${{needs.prepare-env.outputs.short_sha}}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
run: |
# Install python packages needed from ansible
pipx inject ansible-core jmespath openshift pygithub
- name: Deploy qa environment
uses: dawidd6/action-ansible-playbook@e8303e5fa5b52015d59fd5bc8c968943bd5f349c # v6
with:
playbook: playbooks/deploy.yml
directory: ./ansible
requirements: playbooks/requirements.yml
vault_password: ${{secrets.VAULT_PASSWORD}}
options: |
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
--extra-vars "env=qa"
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
--skip-tags ci,import-index-images
--verbose
deploy-stage:
runs-on: ubuntu-latest
environment:
name: stage
env:
SHORT_SHA: ${{needs.prepare-env.outputs.short_sha}}
needs:
- prepare-env
- configure-stage-cluster
- deploy-qa
- deploy-dev
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
run: |
# Install python packages needed from ansible
pipx inject ansible-core jmespath openshift pygithub
- name: Deploy stage environment
uses: dawidd6/action-ansible-playbook@e8303e5fa5b52015d59fd5bc8c968943bd5f349c # v6
with:
playbook: playbooks/deploy.yml
directory: ./ansible
requirements: playbooks/requirements.yml
vault_password: ${{secrets.VAULT_PASSWORD}}
options: |
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
--extra-vars "env=stage"
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
--skip-tags ci,import-index-images
--verbose
configure-prod-cluster:
runs-on: ubuntu-latest
needs:
- prepare-env
- deploy-stage
environment:
name: prod
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
run: |
# Install python packages needed from ansible
pipx inject ansible-core jmespath openshift pygithub
- name: Configure prod cluster
uses: dawidd6/action-ansible-playbook@e8303e5fa5b52015d59fd5bc8c968943bd5f349c # v6
with:
playbook: playbooks/config-ocp-cluster.yml
directory: ./ansible
requirements: playbooks/requirements.yml
vault_password: ${{secrets.VAULT_PASSWORD_PROD}}
options: |
--inventory ./inventory/clusters
--extra-vars "clusters=prod-cluster"
--extra-vars "env=prod"
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
--verbose
deploy-prod:
runs-on: ubuntu-latest
env:
SHORT_SHA: ${{needs.prepare-env.outputs.short_sha}}
needs:
- prepare-env
- configure-prod-cluster
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install dependencies
run: |
# Install python packages needed from ansible
pipx inject ansible-core jmespath openshift pygithub
- name: Deploy prod environment
uses: dawidd6/action-ansible-playbook@e8303e5fa5b52015d59fd5bc8c968943bd5f349c # v6
with:
playbook: playbooks/deploy.yml
directory: ./ansible
requirements: playbooks/requirements.yml
vault_password: ${{secrets.VAULT_PASSWORD_PROD}}
options: |
--extra-vars "operator_pipeline_image_tag=${{ github.sha }}"
--extra-vars "suffix=${{needs.prepare-env.outputs.short_sha}}"
--extra-vars "env=prod"
--extra-vars "ansible_python_interpreter=/opt/pipx/venvs/ansible-core/bin/python3"
--skip-tags ci,import-index-images
--verbose
release:
name: Github release
runs-on: ubuntu-latest
permissions: write-all
needs:
- deploy-prod
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@a22cf08638b34d5badda920f9daf6e72c477b07b # v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a GitHub release
uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Log in to Quay.io
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
registry: quay.io
- name: Tag image with a release tag
run: |
podman pull quay.io/redhat-isv/operator-pipelines-images:${{ github.sha }}
podman tag quay.io/redhat-isv/operator-pipelines-images:${{ github.sha }} quay.io/redhat-isv/operator-pipelines-images:released
podman tag quay.io/redhat-isv/operator-pipelines-images:${{ github.sha }} quay.io/redhat-isv/operator-pipelines-images:${{ steps.tag_version.outputs.new_tag }}
podman push quay.io/redhat-isv/operator-pipelines-images:released
podman push quay.io/redhat-isv/operator-pipelines-images:${{ steps.tag_version.outputs.new_tag }}