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 1616
1717 steps :
1818 - name : Get pull request information
19+ if : github.event_name == 'pull_request_target'
1920 uses : actions/github-script@v7
2021 id : pr
2122 with :
@@ -30,13 +31,13 @@ jobs:
3031 uses : actions/checkout@v4
3132 with :
3233 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 || '' }}
3435
3536 - name : Get changed files
3637 id : changed-files
3738 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
4041 else
4142 echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | xargs)" >> $GITHUB_OUTPUT
4243 fi
8889 fi
8990
9091 - 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 '
9293 uses : actions/github-script@v7
9394 with :
9495 script : |
Original file line number Diff line number Diff line change 1818
1919 steps :
2020 - name : Get pull request information
21+ if : github.event_name == 'pull_request_target'
2122 uses : actions/github-script@v7
2223 id : pr
2324 with :
@@ -32,13 +33,13 @@ jobs:
3233 uses : actions/checkout@v4
3334 with :
3435 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 || '' }}
3637
3738 - name : Get changed files
3839 id : changed-files
3940 run : |
4041 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
4243 else
4344 echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
4445 fi
Original file line number Diff line number Diff line change 1717
1818 steps :
1919 - name : Get pull request information
20+ if : github.event_name == 'pull_request_target'
2021 uses : actions/github-script@v7
2122 id : pr
2223 with :
3132 uses : actions/checkout@v4
3233 with :
3334 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 || '' }}
3536
3637 - name : Set execute permission for .sh files
3738 run : |
4041 - name : Get changed files
4142 id : changed-files
4243 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
4546 else
4647 echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -E '\.(sh|func)$' | xargs)" >> $GITHUB_OUTPUT
4748 fi
@@ -167,7 +168,7 @@ jobs:
167168 fi
168169
169170 - 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 '
171172 uses : actions/github-script@v7
172173 with :
173174 script : |
You can’t perform that action at this time.
0 commit comments