Skip to content

Commit

Permalink
chore: add condition for only building on main
Browse files Browse the repository at this point in the history
ensure that longer-to-build images only get built on main
  • Loading branch information
BobyMCbobs committed Sep 26, 2023
1 parent 8ba139a commit 24a6074
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ jobs:
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- uses: GeoNet/yq@bbe305500687a5fe8498d74883c17f0f06431ac4 # master
- id: set
env:
REF: ${{ github.ref }}
run: |
echo "matrix-docker=$(jq -rMc '.build[] | select(.source | contains("Dockerfile")) | . as $config | .destination | capture("(?<registry>.*)/(?<imageName>.*):(?<tag>.*)") | . as $imgSplit | $config | .source | capture("(?<context>.*)/Dockerfile") | . as $context | $config + $imgSplit + $context' -r -c <<< "$(yq e . -o json config.yaml)" | jq -rcsM '{"include":.}')" >> $GITHUB_OUTPUT
echo "matrix-docker=$(jq --arg REF "$REF" -rMc '.build[] | select(.source | contains("Dockerfile")) | select(.buildOnMain == null or $REF == "refs/heads/main") | . as $config | .destination | capture("(?<registry>.*)/(?<imageName>.*):(?<tag>.*)") | . as $imgSplit | $config | .source | capture("(?<context>.*)/Dockerfile") | . as $context | $config + $imgSplit + $context' -r -c <<< "$(yq e . -o json config.yaml)" | jq -rcsM '{"include":.}')" >> $GITHUB_OUTPUT
echo "matrix-apko=$(jq -rMc '.build[] | select(.source | contains("image.yaml"))' -r -c <<< "$(yq e . -o json config.yaml)" | jq -rcsM '{"include":.}')" >> $GITHUB_OUTPUT
- name: check output
run: |
Expand Down
3 changes: 3 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ build:
destination: ghcr.io/geonet/base-images/chart-centos7:latest
- source: ./images/rpmbuild-centos7/Dockerfile
destination: ghcr.io/geonet/base-images/rpmbuild-centos7:latest
buildOnMain: true
- source: ./images/rpmbuild-centos-stream8/Dockerfile
destination: ghcr.io/geonet/base-images/rpmbuild-centos-stream8:latest
buildOnMain: true
- source: ./images/rpmbuild-centos-stream9/Dockerfile
destination: ghcr.io/geonet/base-images/rpmbuild-centos-stream9:latest
buildOnMain: true

0 comments on commit 24a6074

Please sign in to comment.