File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,11 +32,44 @@ jobs:
3232 path : scripts/build/
3333 retention-days : 1
3434
35+ - name : Determine changed plugins
36+ id : changed-plugins
37+ env :
38+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
39+ REPO : ${{ github.repository }}
40+ PR_NUMBER : ${{ github.event.pull_request.number }}
41+ run : |
42+ set -euo pipefail
43+
44+ if [[ "${{ github.event_name }}" != "pull_request" ]]; then
45+ echo "Not a pull_request event; building all plugins."
46+ echo "apply-filter=false" >> "$GITHUB_OUTPUT"
47+ echo "changed-plugins=" >> "$GITHUB_OUTPUT"
48+ exit 0
49+ fi
50+
51+ changed=$(gh api "repos/$REPO/pulls/$PR_NUMBER/files" --paginate \
52+ --jq '.[] | select(.filename | startswith("plugins/")) | .filename' \
53+ | awk -F/ '{print $1"/"$2}' | sort -u)
54+
55+ echo "Changed plugin paths:"
56+ echo "${changed:-<none>}"
57+
58+ echo "apply-filter=true" >> "$GITHUB_OUTPUT"
59+ {
60+ echo "changed-plugins<<EOF"
61+ echo "$changed"
62+ echo "EOF"
63+ } >> "$GITHUB_OUTPUT"
64+
3565 - name : Discover submodules
3666 id : discover-submodules
67+ env :
68+ APPLY_FILTER : ${{ steps.changed-plugins.outputs.apply-filter }}
69+ CHANGED_PLUGINS : ${{ steps.changed-plugins.outputs.changed-plugins }}
3770 run : |
3871 sudo bash ./scripts/_gen_metadata.sh
39- sudo bash ./scripts/_submodules.sh > submodules.json
72+ sudo -E bash ./scripts/_submodules.sh > submodules.json
4073 cat submodules.json
4174
4275 echo "submodule-matrix=$(cat submodules.json)" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change @@ -4,7 +4,11 @@ submodules=()
44while read -r line; do
55 sha=$( echo " $line " | awk ' {print $1}' )
66 name=$( echo " $line " | awk ' {print $2}' )
7-
7+
8+ if [[ " ${APPLY_FILTER:- false} " == " true" ]] && ! grep -qxF " $name " <<< " ${CHANGED_PLUGINS:-}" ; then
9+ continue
10+ fi
11+
812 url=$( git config --get submodule." $name " .url)
913 if [[ -n " $url " ]]; then
1014 owner=$( echo " $url " | sed -E ' s|https://github.com/([^/]+)/.*|\1|' )
You can’t perform that action at this time.
0 commit comments