Skip to content

Commit 61af43f

Browse files
committed
Extract build step to separate action
The build action is used by both e2e and deployment action and is executed only once.
1 parent f9d8067 commit 61af43f

File tree

7 files changed

+28
-46
lines changed

7 files changed

+28
-46
lines changed

.github/workflows/main-image.yml renamed to .github/workflows/build-image.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
name: Build and Push Image
1+
---
2+
name: Build
3+
24
on: # yamllint disable-line rule:truthy
3-
pull_request:
4-
push:
5+
workflow_run:
6+
workflows:
7+
- validation
58
branches:
69
- main
10+
types:
11+
- completed
12+
workflow_dispatch:
713

814
jobs:
915
build:
1016
name: Build and push image
11-
runs-on: ubuntu-20.04
17+
runs-on: ubuntu-latest
18+
19+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
1220

1321
steps:
1422
- uses: actions/checkout@v2
@@ -31,8 +39,6 @@ jobs:
3139
registry: quay.io/redhat-isv
3240
username: ${{ secrets.REGISTRY_USERNAME }}
3341
password: ${{ secrets.REGISTRY_PASSWORD }}
34-
if: ${{ github.event_name == 'push' }}
3542

3643
- name: Print image url
3744
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
38-
if: ${{ github.event_name == 'push' }}

.github/workflows/ppc64le-image.yml renamed to .github/workflows/build-ppc64le-image.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: Build and Push ppc64le Image
22
on: # yamllint disable-line rule:truthy
3-
pull_request:
4-
push:
3+
workflow_run:
4+
workflows:
5+
- validation
56
branches:
67
- main
8+
types:
9+
- completed
10+
workflow_dispatch:
711

812
jobs:
913
build:

.github/workflows/deploy.yml

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,10 @@ on: # yamllint disable-line rule:truthy
1111
- completed
1212

1313
jobs:
14-
build:
15-
name: Build and push image
16-
runs-on: ubuntu-latest
17-
18-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
19-
20-
steps:
21-
- uses: actions/checkout@v2
22-
23-
- name: Build Image
24-
id: build-image
25-
uses: redhat-actions/buildah-build@v2
26-
with:
27-
image: operator-pipelines-images
28-
tags: latest ${{ github.sha }}
29-
dockerfiles: |
30-
./operator-pipeline-images/Dockerfile
31-
32-
- name: Push To quay.io
33-
id: push-to-quay
34-
uses: redhat-actions/push-to-registry@v2
35-
with:
36-
image: ${{ steps.build-image.outputs.image }}
37-
tags: ${{ steps.build-image.outputs.tags }}
38-
registry: quay.io/redhat-isv
39-
username: ${{ secrets.REGISTRY_USERNAME }}
40-
password: ${{ secrets.REGISTRY_PASSWORD }}
41-
42-
- name: Print image url
43-
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
4414

4515
deploy-dev:
4616
runs-on: ubuntu-latest
47-
needs:
48-
- build
17+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
4918
environment:
5019
name: dev
5120
steps:
@@ -68,8 +37,7 @@ jobs:
6837
6938
deploy-qa:
7039
runs-on: ubuntu-latest
71-
needs:
72-
- build
40+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
7341
environment:
7442
name: qa
7543
steps:

.github/workflows/e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: E2E-CI
77
on: # yamllint disable-line rule:truthy
88
workflow_run:
99
workflows:
10-
- validation
10+
- Build
1111
branches:
1212
- main
1313
types:
@@ -139,7 +139,7 @@ jobs:
139139
run: |
140140
oc new-project $OC_PROJECT
141141
pushd ansible
142-
bash init-custom-env.sh $OC_PROJECT stage vault-password
142+
bash init-custom-env.sh $OC_PROJECT stage vault-password ${{ github.sha }}
143143
popd
144144
145145
- name: Run CI pipeline

.github/workflows/validation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on: # yamllint disable-line rule:truthy
66
push:
77
branches:
88
- main
9+
workflow_dispatch:
910

1011
jobs:
1112
yaml-lint:

ansible/init-custom-env.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ umask 077
1212

1313
NAMESPACE=$1
1414
ENV=$2
15+
PIPELINE_IMAGE_TAG=${4:-released}
1516
SECRET=$(dirname "$0")/vaults/custom/ocp-token.yml
16-
PASSWD_FILE=./vault-password
17+
PASSWD_FILE=$3
1718

1819
# Initialize the environment by creating the service account and giving for it admin permissions
1920
initialize_environment() {
@@ -29,6 +30,7 @@ initialize_environment() {
2930
-e "custom=true" \
3031
-e "ocp_host=`oc whoami --show-server`" \
3132
-e "ocp_token=`oc whoami -t`" \
33+
-e "operator_pipeline_image_tag=$PIPELINE_IMAGE_TAG" \
3234
--tags init \
3335
-vvvv
3436
}

docs/developer-guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ selecting `copy login command`.
3838

3939
```bash
4040
# Assuming the current working directory is ansible/
41-
./init-custom-env.sh $PROJECT $ENVIRONMENT $PASSWD_FILE
41+
./init-custom-env.sh $PROJECT $ENVIRONMENT $PASSWD_FILE [$PIPELINE_IMAGE_TAG]
4242
```
4343

4444
| Argument | Description |
4545
| -------- | ----------- |
4646
| PROJECT | An OpenShift project name (eg. `john-playground`). Pipeline resources will be installed here. |
4747
| ENVIRONMENT | The environmental dependencies and corresponding credentials to leverage. Can be one of `dev`, `qa`, `stage` or `prod`. |
4848
| PASSWD_FILE | File path containing the ansible vault password. |
49+
| PIPELINE_IMAGE_TAG | The tag name of operator pipeline image. (optional) |
4950

5051
:warning: Conflicts may occur if the project already contains some resources. They may need to be removed first.
5152

0 commit comments

Comments
 (0)