Skip to content

Commit 52ea4b5

Browse files
authored
ci: properly handle an empty strategy matrix (#44)
Closes #39 Signed-off-by: Niccolò Fei <niccolo.fei@enterprisedb.com>
1 parent 5f395b8 commit 52ea4b5

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

.github/workflows/bake.yml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,40 @@ jobs:
3636
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
3737
id: filter
3838
with:
39-
base: ${{ (github.event_name == 'schedule') && 'main' || '' }}
4039
filters: |
40+
_shared: &shared
41+
- 'docker-bake.hcl'
42+
- 'Makefile'
43+
- 'kind-config.yaml'
44+
- 'test/**'
45+
- '.github/workflows/bake*.yml'
4146
pgvector:
4247
- 'pgvector/**'
48+
- *shared
4349
postgis:
4450
- 'postgis/**'
51+
- *shared
4552
pgaudit:
4653
- 'pgaudit/**'
54+
- *shared
4755
4856
# Compute a matrix containing the list of all extensions that have been modified
4957
- name: Compute matrix
5058
id: get-matrix
5159
env:
5260
# JSON array containing the extensions that have been changed
53-
EXTENSIONS_CHANGED: ${{ steps.filter.outputs.changes }}
61+
CHANGES: ${{ steps.filter.outputs.changes }}
5462
# Input Extension name
5563
INPUT_EXTENSION_NAME: ${{ github.event.inputs.extension_name }}
5664
run: |
5765
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then
58-
EXTENSIONS_CHANGED="[\"$INPUT_EXTENSION_NAME\"]"
66+
CHANGES="[\"$INPUT_EXTENSION_NAME\"]"
5967
fi
60-
echo "{\"name\": $EXTENSIONS_CHANGED}" > matrix.json
61-
echo "matrix=$(cat matrix.json)" >> "$GITHUB_OUTPUT"
68+
69+
# Filter away the shared filter
70+
EXTENSIONS_CHANGED=$(echo "$CHANGES" | jq -c 'map(select(. != "_shared"))')
71+
72+
echo "matrix=$EXTENSIONS_CHANGED" >> "$GITHUB_OUTPUT"
6273
6374
Bake:
6475
name: Bake
@@ -68,11 +79,13 @@ jobs:
6879
contents: read
6980
id-token: write
7081
security-events: write
82+
if: ${{ join(fromJSON(needs.change-triage.outputs.matrix)) != '' }}
7183
strategy:
7284
fail-fast: false
73-
matrix: ${{ fromJSON(needs.change-triage.outputs.matrix) }}
85+
matrix:
86+
extension: ${{ fromJSON(needs.change-triage.outputs.matrix) }}
7487
uses: ./.github/workflows/bake_targets.yml
7588
with:
76-
extension_name: ${{ matrix.name }}
89+
extension_name: ${{ matrix.extension }}
7790
secrets:
7891
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

0 commit comments

Comments
 (0)