Skip to content

Commit f8e915f

Browse files
committed
refactor to reduce duplication
1 parent 97ecc6b commit f8e915f

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

.github/workflows/build-test-images.yml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
# Need the repo checked out in order to read the file
15-
- uses: actions/checkout@v3
15+
- uses: actions/checkout@v4
1616
- id: get_versions
1717
run: cat circleci/images/PG_VERSIONS >> $GITHUB_OUTPUT
1818
outputs:
@@ -27,18 +27,17 @@ jobs:
2727
packages: write
2828
needs:
2929
- prepare_pgversion_matrix
30+
env:
31+
RELEASE_FLAG: ""
3032
strategy:
3133
fail-fast: false
3234
matrix:
33-
command:
34-
- extbuilder
35-
- exttester
36-
- failtester
35+
command: [extbuilder, exttester, failtester]
3736
pgversion: ${{ fromJSON(needs.prepare_pgversion_matrix.outputs.pgversions) }}
3837

39-
steps:
38+
steps: &build_images_per_pg_steps
4039
- name: Checkout repository
41-
uses: actions/checkout@v2
40+
uses: actions/checkout@v4
4241

4342
- name: 'Login to GitHub Container Registry'
4443
uses: docker/login-action@v3
@@ -48,28 +47,31 @@ jobs:
4847
password: ${{ secrets.GITHUB_TOKEN }}
4948

5049
# If current branch is not master,build and publish dev image
51-
- name: Build & Push all dev images
50+
- name: Build & Push images
5251
run: |
5352
cd circleci/images
54-
make push-${{ matrix.command }}-${{ matrix.pgversion }}
53+
if [ -n "${RELEASE_FLAG}" ]; then
54+
RELEASE=${RELEASE_FLAG} make push-${{ matrix.command }}-${{ matrix.pgversion }}
55+
else
56+
make push-${{ matrix.command }}-${{ matrix.pgversion }}
57+
fi
5558
5659
build_dev_images_shared:
5760
if: github.ref_name != 'master'
5861
name: push-test-images-for-dev
5962
runs-on: ubuntu-latest
6063
permissions:
6164
packages: write
65+
env:
66+
RELEASE_FLAG: ""
6267
strategy:
6368
fail-fast: false
6469
matrix:
65-
command:
66-
- citusupgradetester
67-
- pgupgradetester
68-
- stylechecker
70+
command: [citusupgradetester, pgupgradetester, stylechecker]
6971

70-
steps:
72+
steps: &build_shared_image_steps
7173
- name: Checkout repository
72-
uses: actions/checkout@v2
74+
uses: actions/checkout@v4
7375

7476
- name: 'Login to GitHub Container Registry'
7577
uses: docker/login-action@v3
@@ -79,10 +81,14 @@ jobs:
7981
password: ${{ secrets.GITHUB_TOKEN }}
8082

8183
# If current branch is not master,build and publish dev image
82-
- name: Build & Push all dev images
84+
- name: Build & Push images
8385
run: |
8486
cd circleci/images
85-
make push-${{ matrix.command }}-all
87+
if [ -n "${RELEASE_FLAG}" ]; then
88+
RELEASE=${RELEASE_FLAG} make push-${{ matrix.command }}-all
89+
else
90+
make push-${{ matrix.command }}-all
91+
fi
8692
8793
8894
build_release_images:
@@ -92,32 +98,26 @@ jobs:
9298
runs-on: ubuntu-latest
9399
permissions:
94100
packages: write
101+
env:
102+
RELEASE_FLAG: "1"
95103
strategy:
96104
fail-fast: false
97105
matrix:
98106
command: [extbuilder, exttester, failtester]
99107
pgversion: ${{ fromJSON(needs.prepare_pgversion_matrix.outputs.pgversions) }}
100108

101-
steps:
102-
- name: Checkout repository
103-
uses: actions/checkout@v2
104-
105-
- name: 'Login to GitHub Container Registry'
106-
uses: docker/login-action@v3
107-
with:
108-
registry: ghcr.io
109-
username: ${{ github.actor }}
110-
password: ${{ secrets.GITHUB_TOKEN }}
109+
steps: *build_images_per_pg_steps
111110

112-
- name: Build & Push all live images
113-
run: |
114-
cd circleci/images
115-
RELEASE=1 make push-${{ matrix.command }}-${{ matrix.pgversion }}
116-
- run: docker system prune --all --force --volumes
117-
if: always()
118-
- name: Free Docker space
119-
if: always()
120-
run: |
121-
docker image prune --all --force
122-
docker builder prune --all --force
123-
docker system df
111+
build_release_images_shared:
112+
if: github.ref_name == 'master' || github.ref_name == 'ihalatci-update-workflow'
113+
name: push-shared-images-for-release
114+
runs-on: ubuntu-latest
115+
permissions:
116+
packages: write
117+
env:
118+
RELEASE_FLAG: "1"
119+
strategy:
120+
fail-fast: false
121+
matrix:
122+
command: [citusupgradetester, pgupgradetester, stylechecker]
123+
steps: *build_shared_image_steps

0 commit comments

Comments
 (0)