File tree Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Expand file tree Collapse file tree 3 files changed +13
-10
lines changed Original file line number Diff line number Diff line change 16
16
17
17
steps :
18
18
- name : Get pull request information
19
+ if : github.event_name == 'pull_request_target'
19
20
uses : actions/github-script@v7
20
21
id : pr
21
22
with :
@@ -30,13 +31,13 @@ jobs:
30
31
uses : actions/checkout@v4
31
32
with :
32
33
fetch-depth : 0 # Ensure the full history is fetched for accurate diffing
33
- ref : ${{ fromJSON(steps.pr.outputs.result).merge_commit_sha }}
34
+ ref : ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
34
35
35
36
- name : Get changed files
36
37
id : changed-files
37
38
run : |
38
- if ${{ github.event_name == 'pull_request ' }}; then
39
- echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
39
+ if ${{ github.event_name == 'pull_request_target ' }}; then
40
+ echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ steps.pr.outputs.result && fromJSON(steps.pr.outputs.result).merge_commit_sha }} | xargs)" >> $GITHUB_OUTPUT
40
41
else
41
42
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
42
43
fi
88
89
fi
89
90
90
91
- name : Post results and comment
91
- if : always() && steps.check-scripts.outputs.files != '' && steps.check-json.outputs.files != '' && github.event_name == 'pull_request '
92
+ if : always() && steps.check-scripts.outputs.files != '' && steps.check-json.outputs.files != '' && github.event_name == 'pull_request_target '
92
93
uses : actions/github-script@v7
93
94
with :
94
95
script : |
Original file line number Diff line number Diff line change 18
18
19
19
steps :
20
20
- name : Get pull request information
21
+ if : github.event_name == 'pull_request_target'
21
22
uses : actions/github-script@v7
22
23
id : pr
23
24
with :
@@ -32,13 +33,13 @@ jobs:
32
33
uses : actions/checkout@v4
33
34
with :
34
35
fetch-depth : 0 # Ensure the full history is fetched for accurate diffing
35
- ref : ${{ fromJSON(steps.pr.outputs.result).merge_commit_sha }}
36
+ ref : ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
36
37
37
38
- name : Get changed files
38
39
id : changed-files
39
40
run : |
40
41
if ${{ github.event_name == 'pull_request' }}; then
41
- echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
42
+ echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ steps.pr.outputs.result && fromJSON(steps.pr.outputs.result).merge_commit_sha }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
42
43
else
43
44
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
44
45
fi
Original file line number Diff line number Diff line change 17
17
18
18
steps :
19
19
- name : Get pull request information
20
+ if : github.event_name == 'pull_request_target'
20
21
uses : actions/github-script@v7
21
22
id : pr
22
23
with :
31
32
uses : actions/checkout@v4
32
33
with :
33
34
fetch-depth : 0 # Ensure the full history is fetched for accurate diffing
34
- ref : ${{fromJSON(steps.pr.outputs.result).merge_commit_sha}}
35
+ ref : ${{ github.event_name == 'pull_request_target' && fromJSON(steps.pr.outputs.result).merge_commit_sha || '' }}
35
36
36
37
- name : Set execute permission for .sh files
37
38
run : |
40
41
- name : Get changed files
41
42
id : changed-files
42
43
run : |
43
- if ${{ github.event_name == 'pull_request ' }}; then
44
- echo "files=$(git diff --name-only -r HEAD^1 HEAD | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
44
+ if ${{ github.event_name == 'pull_request_target ' }}; then
45
+ echo "files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ steps.pr.outputs.result && fromJSON(steps.pr.outputs.result).merge_commit_sha }} | xargs)" >> $GITHUB_OUTPUT
45
46
else
46
47
echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
47
48
fi
@@ -167,7 +168,7 @@ jobs:
167
168
fi
168
169
169
170
- name : Post results and comment
170
- if : always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request '
171
+ if : always() && steps.changed-files.outputs.files != '' && github.event_name == 'pull_request_target '
171
172
uses : actions/github-script@v7
172
173
with :
173
174
script : |
You can’t perform that action at this time.
0 commit comments