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
10
jobs :
11
11
lint-java :
12
- # when using pull_request, all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
12
+ permissions : read-all
13
+
14
+ # when using pull_request_target, all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
13
15
if :
14
16
((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
15
17
(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 +20,18 @@ jobs:
18
20
steps :
19
21
- uses : actions/checkout@v4
20
22
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
23
+ # pull_request_target runs the workflow in the context of the base repo
24
+ # as such actions/checkout needs to be explicit configured to retrieve
25
+ # code from the PR.
26
+ ref : refs/pull/${{ github.event.pull_request.number }}/merge
24
27
submodules : recursive
25
28
- name : Lint java
26
29
run : make lint-java
27
30
28
31
unit-test-java :
29
- # when using pull_request, all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
32
+ permissions : read-all
33
+
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
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
43
49
- name : Set up JDK 11
44
50
uses : actions/setup-java@v1
66
72
path : ${{ github.workspace }}/docs/coverage/java/target/site/jacoco-aggregate/
67
73
68
74
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.
75
+ permissions : read-all
76
+
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')))) &&
@@ -101,7 +109,9 @@ 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
+ permissions : read-all
113
+
114
+ # when using pull_request_target, all jobs MUST have this if check for 'ok-to-test' or 'approved' for security purposes.
105
115
if :
106
116
((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
107
117
(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,10 +123,9 @@ jobs:
113
123
steps :
114
124
- uses : actions/checkout@v4
115
125
with :
116
- # pull_request runs the workflow in the context of the base repo
117
- # as such actions/checkout needs to be explicit configured to retrieve
118
- # code from the PR.
119
- ref : refs/pull/${{ github.event.pull_request.number }}/merge
126
+ repository : ${{ github.event.repository.full_name }} # Uses the full repository name
127
+ ref : ${{ github.ref }} # Uses the ref from the event
128
+ token : ${{ secrets.GITHUB_TOKEN }} # Automatically provided token
120
129
submodules : recursive
121
130
- name : Set up JDK 11
122
131
uses : actions/setup-java@v1
0 commit comments