1
1
name : Report Preview URLs
2
2
3
3
on :
4
- pull_request :
4
+ pull_request_target :
5
5
branches : ["develop"]
6
6
paths :
7
7
- ' docs/**.rst'
@@ -17,22 +17,55 @@ jobs:
17
17
pull-requests : write
18
18
19
19
steps :
20
- - name : Checkout repository
20
+ - name : Checkout base branch (for trusted scripts)
21
21
uses : actions/checkout@v4
22
22
with :
23
+ ref : develop
24
+ path : base
25
+
26
+ - name : Checkout PR branch (for file diff)
27
+ uses : actions/checkout@v4
28
+ with :
29
+ ref : ${{ github.event.pull_request.head.sha }}
23
30
fetch-depth : 0
31
+ path : pr
24
32
25
33
- name : Fetch base branch
26
34
run : |
27
- git fetch origin develop:develop
35
+ cd pr
36
+ git remote add upstream https://github.com/${{ github.repository }}.git || true
37
+ git fetch upstream develop
38
+ git branch -f develop upstream/develop
28
39
29
40
- name : Generate comment body
30
41
id : generate-comment
31
42
run : |
32
- chmod +x ci_scripts/report_preview_url.sh
43
+ TRUSTED_USERS=("ooooo-create" "SigureMo")
44
+ PR_AUTHOR="${{ github.event.pull_request.user.login }}"
45
+
46
+ IS_TRUSTED=false
47
+ for user in "${TRUSTED_USERS[@]}"; do
48
+ if [ "$user" == "$PR_AUTHOR" ]; then
49
+ IS_TRUSTED=true
50
+ break
51
+ fi
52
+ done
53
+
54
+ if [ "$IS_TRUSTED" == "true" ]; then
55
+ echo "✅ Using PR branch script (same repo or trusted user: $PR_AUTHOR)"
56
+ chmod +x pr/ci_scripts/report_preview_url.sh
57
+ cd pr
58
+ SCRIPT_PATH="./ci_scripts/report_preview_url.sh"
59
+ else
60
+ echo "🔒 Using base branch script for security (fork from untrusted user: $PR_AUTHOR)"
61
+ chmod +x base/ci_scripts/report_preview_url.sh
62
+ cd pr
63
+ SCRIPT_PATH="../base/ci_scripts/report_preview_url.sh"
64
+ fi
65
+
33
66
{
34
67
echo 'comment_body<<EOF'
35
- ./ci_scripts/report_preview_url.sh ${{ github.event.pull_request.number }}
68
+ $SCRIPT_PATH ${{ github.event.pull_request.number }}
36
69
echo EOF
37
70
} >> $GITHUB_OUTPUT
38
71
0 commit comments