File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1
1
name : " Changed files detection"
2
2
description : " Find the added and modified files due to a github event"
3
+ inputs :
4
+ github-token :
5
+ description : " Github access token."
6
+ required : false
3
7
outputs :
4
8
files :
5
9
description : " Paths of all added or modified files"
16
20
run : |
17
21
set -x
18
22
${{ github.action_path }}/find_changed_files.sh
23
+ env :
24
+ GITHUB_TOKEN : ${{ inputs.github-token }}
19
25
Original file line number Diff line number Diff line change @@ -22,6 +22,14 @@ echo "compare: |$COMPARE|"
22
22
echo " PR: |$PR |"
23
23
echo " ------"
24
24
25
+ if [[ -z " ${GITHUB_TOKEN} " ]]; then
26
+ TOKEN_HEADER=" "
27
+ else
28
+ TOKEN_HEADER=" Authorization: token $GITHUB_TOKEN "
29
+ fi
30
+
31
+ FORMAT_HEADER=" Accept: application/vnd.github.v3+json"
32
+
25
33
if [[ $COMPARE != null ]]
26
34
then
27
35
# compare might be a compare url or a commit url (single commit case)
37
45
exit 1
38
46
fi
39
47
# TODO paginate to support more than 100 files
40
- COMPARE_RESPONSE=$( curl -H " Accept: application/vnd.github.v3+json " " $COMPARE_API ?per_page=100" )
48
+ COMPARE_RESPONSE=$( curl -H $FORMAT_HEADER -H " $TOKEN_HEADER " " $COMPARE_API ?per_page=100" )
41
49
FILES_JSON=$( echo $COMPARE_RESPONSE | jq -r ' .files' )
42
50
elif [[ $PR != null ]]
43
51
then
44
52
# this is a PR, using its files API
45
53
PR_FILES_API=" $PR /files"
46
54
# TODO paginate to support more than 100 files
47
- FILES_JSON=$( curl -H " Accept: application/vnd.github.v3+json " " $PR_FILES_API ?per_page=100" )
55
+ FILES_JSON=$( curl -H $FORMAT_HEADER -H " $TOKEN_HEADER " " $PR_FILES_API ?per_page=100" )
48
56
else
49
57
echo " CANNOT FIND CHANGED FILES"
50
58
exit 1
You can’t perform that action at this time.
0 commit comments