Skip to content

Commit 83320c9

Browse files
committed
Configure CI/CD to use a latest image build
The deploy action was extended with a build configuration and the individual steps of release use the image with a latest commit sha. JIRA: ISV-1363, ISV-1364
1 parent 6acba38 commit 83320c9

File tree

3 files changed

+130
-54
lines changed

3 files changed

+130
-54
lines changed

.github/workflows/deploy.yml

Lines changed: 119 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,48 @@ on: # yamllint disable-line rule:truthy
77
- E2E-CI
88
branches:
99
- main
10+
- ci-cd
1011
types:
1112
- completed
13+
push:
14+
branches:
15+
- ci-cd
1216
workflow_dispatch:
1317

1418
jobs:
19+
build:
20+
name: Build and push image
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: Build Image
27+
id: build-image
28+
uses: redhat-actions/buildah-build@v2
29+
with:
30+
image: operator-pipelines-images
31+
tags: latest ${{ github.sha }}
32+
dockerfiles: |
33+
./operator-pipeline-images/Dockerfile
34+
35+
- name: Push To quay.io
36+
id: push-to-quay
37+
uses: redhat-actions/push-to-registry@v2
38+
with:
39+
image: ${{ steps.build-image.outputs.image }}
40+
tags: ${{ steps.build-image.outputs.tags }}
41+
registry: quay.io/redhat-isv
42+
username: ${{ secrets.REGISTRY_USERNAME }}
43+
password: ${{ secrets.REGISTRY_PASSWORD }}
44+
45+
- name: Print image url
46+
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
47+
1548
deploy-dev:
1649
runs-on: ubuntu-latest
50+
needs:
51+
- build
1752
environment:
1853
name: dev
1954
steps:
@@ -30,12 +65,14 @@ jobs:
3065
vault_password: ${{secrets.VAULT_PASSWORD}}
3166
options: |
3267
--inventory inventory/operator-pipeline
33-
--extra-vars env=dev
68+
--extra-vars "env=dev operator_pipeline_image_tag=${{ github.sha }}"
3469
--skip-tags ci
3570
--verbose
3671
3772
deploy-qa:
3873
runs-on: ubuntu-latest
74+
needs:
75+
- build
3976
environment:
4077
name: qa
4178
steps:
@@ -52,55 +89,94 @@ jobs:
5289
vault_password: ${{secrets.VAULT_PASSWORD}}
5390
options: |
5491
--inventory inventory/operator-pipeline
55-
--extra-vars env=qa
92+
--extra-vars "env=qa operator_pipeline_image_tag=${{ github.sha }}"
5693
--skip-tags ci
5794
--verbose
5895
59-
deploy-stage:
96+
# deploy-stage:
97+
# runs-on: ubuntu-latest
98+
# environment:
99+
# name: stage
100+
# needs:
101+
# - deploy-qa
102+
# - deploy-dev
103+
# steps:
104+
# - uses: actions/checkout@v1
105+
# - name: Install dependencies
106+
# run: |
107+
# pip install --user openshift
108+
# - name: Deploy stage environment
109+
# uses: dawidd6/action-ansible-playbook@v2
110+
# with:
111+
# playbook: playbooks/deploy.yml
112+
# directory: ./ansible
113+
# requirements: playbooks/requirements.yml
114+
# vault_password: ${{secrets.VAULT_PASSWORD}}
115+
# options: |
116+
# --inventory inventory/operator-pipeline
117+
# --extra-vars "env=stage operator_pipeline_image_tag=${{ github.sha }}"
118+
# --skip-tags ci
119+
# --verbose
120+
121+
# deploy-prod:
122+
# runs-on: ubuntu-latest
123+
# environment:
124+
# name: prod
125+
# needs:
126+
# - deploy-stage
127+
# steps:
128+
# - uses: actions/checkout@v1
129+
# - name: Install dependencies
130+
# run: |
131+
# pip install --user openshift
132+
# - name: Deploy prod environment
133+
# uses: dawidd6/action-ansible-playbook@v2
134+
# with:
135+
# playbook: playbooks/deploy.yml
136+
# directory: ./ansible
137+
# requirements: playbooks/requirements.yml
138+
# vault_password: ${{secrets.VAULT_PASSWORD}}
139+
# options: |
140+
# --inventory inventory/operator-pipeline
141+
# --extra-vars "env=prod operator_pipeline_image_tag=${{ github.sha }}"
142+
# --skip-tags ci
143+
# --verbose
144+
release:
145+
name: Github release
60146
runs-on: ubuntu-latest
61-
environment:
62-
name: stage
63147
needs:
64148
- deploy-dev
65-
- deploy-qa
66149
steps:
67-
- uses: actions/checkout@v1
68-
- name: Install dependencies
69-
run: |
70-
pip install --user openshift
71-
- name: Deploy stage environment
72-
uses: dawidd6/action-ansible-playbook@v2
150+
- uses: actions/checkout@v2
151+
152+
- name: Bump version and push tag
153+
id: tag_version
154+
uses: mathieudutour/[email protected]
73155
with:
74-
playbook: playbooks/deploy.yml
75-
directory: ./ansible
76-
requirements: playbooks/requirements.yml
77-
vault_password: ${{secrets.VAULT_PASSWORD}}
78-
options: |
79-
--inventory inventory/operator-pipeline
80-
--extra-vars env=stage
81-
--skip-tags ci
82-
--verbose
156+
github_token: ${{ secrets.GITHUB_TOKEN }}
83157

84-
deploy-prod:
85-
runs-on: ubuntu-latest
86-
environment:
87-
name: prod
88-
needs:
89-
- deploy-stage
90-
steps:
91-
- uses: actions/checkout@v1
92-
- name: Install dependencies
93-
run: |
94-
pip install --user openshift
95-
- name: Deploy prod environment
96-
uses: dawidd6/action-ansible-playbook@v2
158+
- name: Create a GitHub release
159+
uses: actions/create-release@v1
160+
env:
161+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97162
with:
98-
playbook: playbooks/deploy.yml
99-
directory: ./ansible
100-
requirements: playbooks/requirements.yml
101-
vault_password: ${{secrets.VAULT_PASSWORD}}
102-
options: |
103-
--inventory inventory/operator-pipeline
104-
--extra-vars env=prod
105-
--skip-tags ci
106-
--verbose
163+
tag_name: ${{ steps.tag_version.outputs.new_tag }}
164+
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
165+
body: ${{ steps.tag_version.outputs.changelog }}
166+
167+
- name: Log in to Quay.io
168+
uses: redhat-actions/podman-login@v1
169+
with:
170+
username: ${{ secrets.REGISTRY_USERNAME }}
171+
password: ${{ secrets.REGISTRY_PASSWORD }}
172+
registry: quay.io
173+
174+
- name: Pull and tag image
175+
run: |
176+
podman pull quay.io/redhat-isv/operator-pipelines-images:${{ github.sha }}
177+
178+
podman tag quay.io/redhat-isv/operator-pipelines-images:${{ github.sha }} quay.io/redhat-isv/operator-pipelines-images:released
179+
podman tag quay.io/redhat-isv/operator-pipelines-images:${{ github.sha }} quay.io/redhat-isv/operator-pipelines-images:${{ steps.tag_version.outputs.new_tag }}
180+
181+
podman push quay.io/redhat-isv/operator-pipelines-images:released
182+
podman push quay.io/redhat-isv/operator-pipelines-images:${{ steps.tag_version.outputs.new_tag }}

.github/workflows/main-image.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ on: # yamllint disable-line rule:truthy
44
- pull_request
55

66
jobs:
7-
test-lint:
8-
name: Run unit tests and linters
9-
runs-on: ubuntu-latest
10-
steps:
11-
- uses: actions/checkout@v2
12-
- uses: fedora-python/[email protected]
13-
with:
14-
tox_env: black,test
15-
dnf_install: krb5-devel krb5-workstation
16-
177
build:
188
name: Build and push image
199
runs-on: ubuntu-20.04

.github/workflows/validation.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,19 @@ on: # yamllint disable-line rule:truthy
66
- pull_request
77

88
jobs:
9-
linting:
9+
yaml-lint:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v1
1313
- name: yaml-lint
1414
uses: ibiqlik/action-yamllint@v3
15+
16+
tox:
17+
name: Run unit tests and linters
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: fedora-python/[email protected]
22+
with:
23+
tox_env: black,test
24+
dnf_install: krb5-devel krb5-workstation

0 commit comments

Comments
 (0)