Skip to content

Commit 98c036c

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

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

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

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,47 @@
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

1113
jobs:
14+
check-image-existence:
15+
name: Build and push ODH/CFO image
16+
runs-on: ubuntu-latest
17+
outputs:
18+
image-found: ${{ steps.image.outputs.found }}
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Verify that the latest images are available on Quay
23+
id: image
24+
run: |
25+
imageTag=$(cat config/manager/params.env | grep codeflare-operator-controller-image | cut -d ':' -f2)
26+
size=$(curl -s https://quay.io/api/v1/repository/project-codeflare/codeflare-operator/tag/?specificTag=$imageTag | jq .tags[0].size)
27+
if [[ "$size" -eq 0 ]]; then
28+
echo "Operator image with tag $imageTag not found in Quay.io, will be built."
29+
echo "found=false" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "Operator image with tag $imageTag found in Quay.io"
32+
fi
33+
1234
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'
35+
needs: [check-image-existence]
36+
if: ${{ needs.check-image-existence.outputs.image-found == 'false' }}
37+
1438
name: Build and push ODH/CFO image
1539
runs-on: ubuntu-latest
1640
steps:
17-
- uses: actions/checkout@v3
41+
- uses: actions/checkout@v4
1842

1943
- name: Set Go
20-
uses: actions/setup-go@v3
44+
uses: actions/setup-go@v5
2145
with:
22-
go-version: v1.20
46+
go-version-file: './go.mod'
2347

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

config/manager/params.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
codeflare-operator-controller-image=quay.io/opendatahub/codeflare-operator:v1.4.0
1+
codeflare-operator-controller-image=quay.io/opendatahub/codeflare-operator:v1.4.1
22
namespace=opendatahub

0 commit comments

Comments
 (0)