11name : java_pr
22
33on :
4- pull_request :
4+ pull_request_target :
55 types :
66 - opened
77 - synchronize
88 - labeled
99
10+ permissions :
11+ pull-requests : read
12+
1013jobs :
1114 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.
1316 if :
1417 ((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
1518 (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:
1821 steps :
1922 - uses : actions/checkout@v4
2023 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
2428 submodules : recursive
29+ persist-credentials : false
2530 - name : Lint java
2631 run : make lint-java
2732
2833 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.
3035 if :
3136 ((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
3237 (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:
3641 steps :
3742 - uses : actions/checkout@v4
3843 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
4248 submodules : recursive
49+ persist-credentials : false
4350 - name : Set up JDK 11
4451 uses : actions/setup-java@v1
4552 with :
6673 path : ${{ github.workspace }}/docs/coverage/java/target/site/jacoco-aggregate/
6774
6875 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.
7077 if :
7178 ((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
7279 (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')))) &&
8289 - uses : actions/checkout@v4
8390 with :
8491 submodules : ' true'
92+ persist-credentials : false
8593 - name : Setup Python
8694 uses : actions/setup-python@v5
8795 id : setup-python
@@ -101,7 +109,7 @@ jobs:
101109 run : make build-${{ matrix.component }}-docker REGISTRY=${REGISTRY} VERSION=${GITHUB_SHA}
102110
103111 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.
105113 if :
106114 ((github.event.action == 'labeled' && (github.event.label.name == 'approved' || github.event.label.name == 'lgtm' || github.event.label.name == 'ok-to-test')) ||
107115 (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:
113121 steps :
114122 - uses : actions/checkout@v4
115123 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
117125 # as such actions/checkout needs to be explicit configured to retrieve
118126 # code from the PR.
119127 ref : refs/pull/${{ github.event.pull_request.number }}/merge
120128 submodules : recursive
129+ persist-credentials : false
121130 - name : Set up JDK 11
122131 uses : actions/setup-java@v1
123132 with :
0 commit comments