1
1
name : java_pr
2
2
3
3
on :
4
- pull_request :
4
+ pull_request_target :
5
5
types :
6
6
- opened
7
7
- synchronize
8
8
- labeled
9
9
10
+ permissions :
11
+ # actions: read
12
+ pull-requests : read
13
+
10
14
jobs :
11
15
lint-java :
12
- # when using pull_request , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
16
+ # when using pull_request_target , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
13
17
if :
14
18
((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
15
19
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, 'ok-to-test') || contains(github.event.pull_request.labels.*.name, 'approved') || contains(github.event.pull_request.labels.*.name, 'lgtm')))) &&
@@ -18,15 +22,17 @@ jobs:
18
22
steps :
19
23
- uses : actions/checkout@v4
20
24
with :
21
- repository : ${{ github.event.repository.full_name }} # Uses the full repository name
22
- ref : ${{ github.ref }} # Uses the ref from the event
23
- token : ${{ secrets.GITHUB_TOKEN }} # Automatically provided token
25
+ # pull_request_target runs the workflow in the context of the base repo
26
+ # as such actions/checkout needs to be explicit configured to retrieve
27
+ # code from the PR.
28
+ ref : refs/pull/${{ github.event.pull_request.number }}/merge
24
29
submodules : recursive
30
+ persist-credentials : false
25
31
- name : Lint java
26
32
run : make lint-java
27
33
28
34
unit-test-java :
29
- # when using pull_request , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
35
+ # when using pull_request_target , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
30
36
if :
31
37
((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
32
38
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, 'ok-to-test') || contains(github.event.pull_request.labels.*.name, 'approved') || contains(github.event.pull_request.labels.*.name, 'lgtm')))) &&
@@ -36,10 +42,12 @@ jobs:
36
42
steps :
37
43
- uses : actions/checkout@v4
38
44
with :
39
- repository : ${{ github.event.repository.full_name }} # Uses the full repository name
40
- ref : ${{ github.ref }} # Uses the ref from the event
41
- token : ${{ secrets.GITHUB_TOKEN }} # Automatically provided token
45
+ # pull_request_target runs the workflow in the context of the base repo
46
+ # as such actions/checkout needs to be explicit configured to retrieve
47
+ # code from the PR.
48
+ ref : refs/pull/${{ github.event.pull_request.number }}/merge
42
49
submodules : recursive
50
+ persist-credentials : false
43
51
- name : Set up JDK 11
44
52
uses : actions/setup-java@v1
45
53
with :
66
74
path : ${{ github.workspace }}/docs/coverage/java/target/site/jacoco-aggregate/
67
75
68
76
build-docker-image-java :
69
- # when using pull_request , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
77
+ # when using pull_request_target , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
70
78
if :
71
79
((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
72
80
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, 'ok-to-test') || contains(github.event.pull_request.labels.*.name, 'approved') || contains(github.event.pull_request.labels.*.name, 'lgtm')))) &&
82
90
- uses : actions/checkout@v4
83
91
with :
84
92
submodules : ' true'
93
+ persist-credentials : false
85
94
- name : Setup Python
86
95
uses : actions/setup-python@v5
87
96
id : setup-python
@@ -101,7 +110,7 @@ jobs:
101
110
run : make build-${{ matrix.component }}-docker REGISTRY=${REGISTRY} VERSION=${GITHUB_SHA}
102
111
103
112
integration-test-java-pr :
104
- # when using pull_request , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
113
+ # when using pull_request_target , all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
105
114
if :
106
115
((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
107
116
(github.event.action != 'labeled' && (contains(github.event.pull_request.labels.*.name, 'ok-to-test') || contains(github.event.pull_request.labels.*.name, 'approved') || contains(github.event.pull_request.labels.*.name, 'lgtm')))) &&
@@ -113,11 +122,12 @@ jobs:
113
122
steps :
114
123
- uses : actions/checkout@v4
115
124
with :
116
- # pull_request runs the workflow in the context of the base repo
125
+ # pull_request_target runs the workflow in the context of the base repo
117
126
# as such actions/checkout needs to be explicit configured to retrieve
118
127
# code from the PR.
119
128
ref : refs/pull/${{ github.event.pull_request.number }}/merge
120
129
submodules : recursive
130
+ persist-credentials : false
121
131
- name : Set up JDK 11
122
132
uses : actions/setup-java@v1
123
133
with :
0 commit comments