@@ -20,14 +20,54 @@ defaults:
2020 shell : pwsh
2121
2222jobs :
23+ select :
24+ name : Select packages
25+ runs-on : ubuntu-latest
26+ timeout-minutes : 5
27+ outputs :
28+ packages : ${{ steps.select.outputs.packages }}
29+ steps :
30+ - name : Checkout repository
31+ uses : actions/checkout@v4
32+ with :
33+ fetch-depth : 0
34+
35+ - name : Select packages to test
36+ id : select
37+ shell : bash
38+ run : |
39+ all='["git-sumi","shuku","zola"]'
40+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
41+ if [ "${{ inputs.package }}" = "all" ]; then
42+ packages="$all"
43+ else
44+ packages='["${{ inputs.package }}"]'
45+ fi
46+ else
47+ changed=$(git diff --name-only \
48+ "${{ github.event.pull_request.base.sha }}" \
49+ "${{ github.event.pull_request.head.sha }}")
50+ if echo "$changed" | grep -qE '^(\.github/workflows/|scripts/)'; then
51+ packages="$all"
52+ else
53+ packages=$(echo "$changed" \
54+ | awk -F/ '/^(git-sumi|shuku|zola)\//{print $1}' \
55+ | sort -u | jq -R . | jq -sc .)
56+ fi
57+ fi
58+ echo "Testing: $packages"
59+ echo "packages=$packages" >> "$GITHUB_OUTPUT"
60+
2361 test :
2462 name : Test ${{ matrix.package }}
63+ needs : select
64+ if : needs.select.outputs.packages != '[]'
2565 runs-on : windows-latest
2666 timeout-minutes : 15
2767 strategy :
2868 fail-fast : false
2969 matrix :
30- package : ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.package != 'all') && fromJson(format('["{0}"]', github.event.inputs.package)) || fromJson('["git-sumi", "shuku", "zola"]' ) }}
70+ package : ${{ fromJson(needs.select.outputs.packages ) }}
3171 steps :
3272 - name : Checkout repository
3373 uses : actions/checkout@v4
0 commit comments