Skip to content

Commit d58a40c

Browse files
committed
Check and build image on push
1 parent 3433d04 commit d58a40c

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

.github/workflows/build-and-push.yaml

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,50 @@
33
name: Build and Push
44

55
on:
6-
pull_request:
7-
types:
8-
- closed
6+
push:
7+
branches:
8+
- 'main'
9+
paths:
10+
- 'config/manager/params.env'
911
workflow_dispatch:
1012

13+
env:
14+
IMAGE_FOUND: 'false'
15+
1116
jobs:
17+
check-image-existence:
18+
name: Build and push ODH/CFO image
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set Go
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version-file: './go.mod'
27+
28+
- name: Verify that the latest images are available on Quay
29+
run: |
30+
imageTag=$(cat config/manager/params.env | grep codeflare-operator-controller-image | cut -d ':' -f2)
31+
size=$(curl -s https://quay.io/api/v1/repository/project-codeflare/codeflare-operator/tag/?specificTag=$imageTag | jq .tags[0].size)
32+
if [[ "$size" -ne 0 ]]; then
33+
echo "Operator image with tag $imageTag found in Quay.io, skipping image build"
34+
echo "IMAGE_FOUND=true" >> "$GITHUB_ENV"
35+
fi
36+
1237
build-and-push:
13-
if: (github.event.pull_request.merged == true && github.event.pull_request.user.login == 'codeflare-machine-account' && contains(github.event.pull_request.title, 'Sync with Upstream')) || github.event_name == 'workflow_dispatch'
38+
needs: [check-image-existence]
39+
if: ${{ env.IMAGE_FOUND == 'true' }}
40+
1441
name: Build and push ODH/CFO image
1542
runs-on: ubuntu-latest
1643
steps:
17-
- uses: actions/checkout@v3
44+
- uses: actions/checkout@v4
1845

1946
- name: Set Go
20-
uses: actions/setup-go@v3
47+
uses: actions/setup-go@v5
2148
with:
22-
go-version: v1.20
49+
go-version-file: './go.mod'
2350

2451
- name: Login to Quay.io
2552
uses: redhat-actions/podman-login@v1

0 commit comments

Comments
 (0)