Skip to content

Commit c74afa0

Browse files
committed
Replace dorny/paths-filter with native git diff
Use native git commands to detect path changes instead of the dorny/paths-filter action, which is not ProdSec approved. The replacement script handles both pull_request and push events, and includes handling for initial pushes where there is no previous commit to compare against.
1 parent 8e508e8 commit c74afa0

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

.github/workflows/main.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,37 @@ jobs:
1414
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1515
with:
1616
fetch-depth: 0
17-
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
17+
- name: Check for path changes
1818
id: changes
19-
with:
20-
filters: |
21-
functions:
22-
- 'functions/**'
23-
ui:
24-
- 'ui/**'
19+
run: |
20+
if [ "${{ github.event_name }}" == "pull_request" ]; then
21+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
22+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
23+
else
24+
# For push events, compare with previous commit
25+
BASE_SHA="${{ github.event.before }}"
26+
HEAD_SHA="${{ github.sha }}"
27+
# Handle initial push (no previous commit)
28+
if [ "$BASE_SHA" == "0000000000000000000000000000000000000000" ]; then
29+
echo "functions=true" >> $GITHUB_OUTPUT
30+
echo "ui=true" >> $GITHUB_OUTPUT
31+
exit 0
32+
fi
33+
fi
34+
35+
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA)
36+
37+
if echo "$CHANGED_FILES" | grep -q '^functions/'; then
38+
echo "functions=true" >> $GITHUB_OUTPUT
39+
else
40+
echo "functions=false" >> $GITHUB_OUTPUT
41+
fi
42+
43+
if echo "$CHANGED_FILES" | grep -q '^ui/'; then
44+
echo "ui=true" >> $GITHUB_OUTPUT
45+
else
46+
echo "ui=false" >> $GITHUB_OUTPUT
47+
fi
2548
2649
test-functions:
2750
needs: check-changes

0 commit comments

Comments
 (0)