From 2c9fb6b949e418abc3732215d3c411419df4827e Mon Sep 17 00:00:00 2001 From: Callum Loh Date: Thu, 1 Sep 2022 18:19:42 +0100 Subject: [PATCH 1/3] Move collecting modified images to script so can set pipefail --- .github/scripts/fetch-modified-images.sh | 17 +++++++++++++++++ .github/workflows/image-rebuild.yaml | 14 +------------- .github/workflows/pr-validate.yaml | 14 +------------- 3 files changed, 19 insertions(+), 26 deletions(-) create mode 100755 .github/scripts/fetch-modified-images.sh diff --git a/.github/scripts/fetch-modified-images.sh b/.github/scripts/fetch-modified-images.sh new file mode 100755 index 00000000..c08acbf8 --- /dev/null +++ b/.github/scripts/fetch-modified-images.sh @@ -0,0 +1,17 @@ +# Gets changed images from GIT + +set -euo pipefail + + +declare -a changes_array=() +while read -r app +do + while read -r channel + do + change="$(jo app="$app" channel="$channel")" + changes_array+=($change) + done < <(jq --raw-output -c '.channels[] | .name' "./apps/$app/metadata.json") +done < <(echo '${{ needs.pr-metadata.outputs.addedOrModifiedImages }}' | jq --raw-output -c '.[]') + +output="$(jo -a ${changes_array[*]})" +echo "::set-output name=changes::${output}" diff --git a/.github/workflows/image-rebuild.yaml b/.github/workflows/image-rebuild.yaml index 9d07d7ce..85e6bf3d 100644 --- a/.github/workflows/image-rebuild.yaml +++ b/.github/workflows/image-rebuild.yaml @@ -44,19 +44,7 @@ jobs: - name: Fetch modified images id: get-changed shell: bash - run: | - declare -a changes_array=() - while read -r app - do - while read -r channel - do - change="$(jo app="$app" channel="$channel")" - changes_array+=($change) - done < <(jq -r '.channels[] | .name' "./apps/$app/metadata.json") - done < <(echo '${{ needs.get-changes.outputs.addedOrModifiedImages }}' | jq --raw-output -c '.[]') - - output="$(jo -a ${changes_array[*]})" - echo "::set-output name=changes::${output}" + run: ./.github/scripts/fetch-modified-images.sh images-build: uses: cdloh/containers/.github/workflows/action-image-build.yaml@main diff --git a/.github/workflows/pr-validate.yaml b/.github/workflows/pr-validate.yaml index ebf017a9..6b938f73 100644 --- a/.github/workflows/pr-validate.yaml +++ b/.github/workflows/pr-validate.yaml @@ -34,19 +34,7 @@ jobs: - name: Fetch modified images id: get-changed shell: bash - run: | - declare -a changes_array=() - while read -r app - do - while read -r channel - do - change="$(jo app="$app" channel="$channel")" - changes_array+=($change) - done < <(jq --raw-output -c '.channels[] | .name' "./apps/$app/metadata.json") - done < <(echo '${{ needs.pr-metadata.outputs.addedOrModifiedImages }}' | jq --raw-output -c '.[]') - - output="$(jo -a ${changes_array[*]})" - echo "::set-output name=changes::${output}" + run: ./.github/scripts/fetch-modified-images.sh images-build: uses: cdloh/containers/.github/workflows/action-image-build.yaml@main From 939cfc7bd3800779c2b485da5f430a6657c1bf3f Mon Sep 17 00:00:00 2001 From: Callum Loh Date: Thu, 1 Sep 2022 18:21:28 +0100 Subject: [PATCH 2/3] Test script --- apps/calibre/metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/calibre/metadata.json b/apps/calibre/metadata.json index 91c7cc60..06c4cfb6 100644 --- a/apps/calibre/metadata.json +++ b/apps/calibre/metadata.json @@ -22,7 +22,7 @@ ], "stable": true, "tests": { - "enabled": false, + "enabled": false,fd } } ] From 9a0252caee2770b8105f222d853d3ec89af4639c Mon Sep 17 00:00:00 2001 From: Callum Loh Date: Thu, 1 Sep 2022 18:25:50 +0100 Subject: [PATCH 3/3] Set -e on jq commands --- .github/scripts/fetch-modified-images.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/fetch-modified-images.sh b/.github/scripts/fetch-modified-images.sh index c08acbf8..f089138a 100755 --- a/.github/scripts/fetch-modified-images.sh +++ b/.github/scripts/fetch-modified-images.sh @@ -10,8 +10,8 @@ do do change="$(jo app="$app" channel="$channel")" changes_array+=($change) - done < <(jq --raw-output -c '.channels[] | .name' "./apps/$app/metadata.json") -done < <(echo '${{ needs.pr-metadata.outputs.addedOrModifiedImages }}' | jq --raw-output -c '.[]') + done < <(jq -e --raw-output -c '.channels[] | .name' "./apps/$app/metadata.json") +done < <(echo '${{ needs.pr-metadata.outputs.addedOrModifiedImages }}' | jq -e --raw-output -c '.[]') output="$(jo -a ${changes_array[*]})" echo "::set-output name=changes::${output}"