-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.sh
More file actions
executable file
·36 lines (32 loc) · 801 Bytes
/
main.sh
File metadata and controls
executable file
·36 lines (32 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
INPUT_BASE_DIR=$1
INPUT_DIFF_FILTER=$2
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
BASE_REF=$(git rev-parse origin/${GITHUB_BASE_REF})
HEAD_REF=$(git rev-parse HEAD)
elif [ "${GITHUB_EVENT_NAME}" == "push" ]; then
BASE_REF=HEAD
HEAD_REF="HEAD^"
else
echo "TheProjectAurora/diff-filter action supports only 'pull_request' and 'commit' events." >> ${GITHUB_OUTPUT}
BASE_REF=HEAD
HEAD_REF=HEAD
fi
AOUTPUT_TMP=$(
git \
--no-pager \
diff \
--name-only \
--diff-filter=${INPUT_DIFF_FILTER} \
${BASE_REF} \
${HEAD_REF} | \
grep ^${INPUT_BASE_DIR} | \
xargs -n 1 dirname | \
awk -F/ '{print $2}' | \
sort | \
uniq | \
jq --raw-input . | \
jq --slurp . | \
tr -d "\ \n\r"
)
echo "dirs=${AOUTPUT_TMP}">>${GITHUB_OUTPUT}