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