Skip to content

Commit 31e3ef1

Browse files
committed
refactor: dynamically detect images for OpenShift import
- Remove hardcoded image matrix - Auto-detect all directories with Containerfile - Add --confirm flag to create ImageStream if missing
1 parent 501fdc4 commit 31e3ef1

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

.github/workflows/pull.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,28 @@ permissions:
1111
contents: read
1212

1313
jobs:
14-
import:
14+
detect:
1515
runs-on: ubuntu-latest
1616
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
outputs:
18+
images: ${{ steps.find.outputs.images }}
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Find all images
24+
id: find
25+
run: |
26+
images=$(find . -maxdepth 2 -name Containerfile | cut -d'/' -f2 | jq -R -s -c 'split("\n") | map(select(length > 0))')
27+
echo "images=$images" >> "$GITHUB_OUTPUT"
28+
29+
import:
30+
needs: detect
31+
if: needs.detect.outputs.images != '[]'
32+
runs-on: ubuntu-latest
1733
strategy:
1834
matrix:
19-
image:
20-
- runner
35+
image: ${{ fromJson(needs.detect.outputs.images) }}
2136

2237
steps:
2338
- name: Connect to Cloudflare WARP
@@ -38,4 +53,4 @@ jobs:
3853
insecure_skip_tls_verify: true
3954

4055
- name: Import image to OpenShift
41-
run: oc import-image ${{ matrix.image }} -n public-registry
56+
run: oc import-image ${{ matrix.image }} -n public-registry --confirm

0 commit comments

Comments
 (0)