9
9
# See https://docs.github.com/en/actions
10
10
# for more information about GitHub actions.
11
11
12
- name : GitHub Actions Build
12
+ name : GH Actions CI
13
13
14
14
on :
15
15
push :
24
24
- ' !wip/**/dependency-update/**'
25
25
tags :
26
26
- ' **'
27
- # WARNING: Using pull_request_target to access secrets, but we check out the merge commit.
28
- # See checkout action for details.
29
- pull_request_target :
27
+ pull_request :
30
28
types : [opened, synchronize, reopened, ready_for_review]
31
29
branches :
32
30
# Pattern order matters: the last matching inclusion/exclusion wins
44
42
45
43
concurrency :
46
44
group : " workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
47
- cancel-in-progress : ${{ github.event_name == 'pull_request_target ' || github.repository != 'hibernate/hibernate-search' }}
45
+ cancel-in-progress : ${{ github.event_name == 'pull_request ' || github.repository != 'hibernate/hibernate-search' }}
48
46
49
47
defaults :
50
48
run :
90
88
- name : Support longpaths on Windows
91
89
if : " startsWith(matrix.os.runs-on, 'windows')"
92
90
run : git config --global core.longpaths true
93
- - name : Check out commit already pushed to branch
94
- if : " ! github.event.pull_request.number"
95
- uses : actions/checkout@v4
96
- - name : Check out PR head
97
- uses : actions/checkout@v4
98
- if : github.event.pull_request.number
91
+ - uses : actions/checkout@v4
99
92
with :
100
- # WARNING: This is potentially dangerous since we're checking out unreviewed code,
101
- # and since we're using the pull_request_target event we can use secrets.
102
- # Thus, we must be extra careful to never expose secrets to steps that execute this code,
103
- # and to strictly limit our of secrets to those that only pose minor security threads.
104
- # This means in particular we won't expose Develocity credentials to the main maven executions,
105
- # but instead will execute maven a third time just to push build scans to Develocity;
106
- # see below.
107
- ref : " refs/pull/${{ github.event.pull_request.number }}/head"
93
+ persist-credentials : false
108
94
# Fetch the whole history to make sure that gitflow incremental builder
109
95
# can find the base commit.
110
96
fetch-depth : 0
@@ -118,9 +104,10 @@ jobs:
118
104
uses : actions/cache@v4
119
105
with :
120
106
path : ~/.m2/repository
121
- key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
107
+ # use a different key than workflows running in trusted mode
108
+ key : ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
122
109
restore-keys : |
123
- ${{ runner.os }}-maven-
110
+ ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-
124
111
- name : Set up Maven
125
112
run : ./mvnw -v
126
113
- name : Docker cleanup
@@ -131,35 +118,37 @@ jobs:
131
118
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
132
119
-Pjqassistant -Pdist -Pci-build -DskipITs
133
120
env :
134
- # WARNING: exposes secrets, so must only be passed to a step that doesn't run unapproved code.
135
- DEVELOCITY_ACCESS_KEY : " ${{ github.event_name == 'push' && secrets.GRADLE_ENTERPRISE_ACCESS_KEY || '' }}"
136
- - name : Publish Develocity build scan for previous build (pull request)
137
- # Don't fail a build if publishing fails
138
- continue-on-error : true
139
- if : " ${{ !cancelled() && github.event_name == 'pull_request_target' && github.repository == 'hibernate/hibernate-search' }}"
140
- run : |
141
- ./mvnw $MAVEN_ARGS develocity:build-scan-publish-previous
142
- env :
143
- # WARNING: exposes secrets, so must only be passed to a step that doesn't run unapproved code.
144
- DEVELOCITY_ACCESS_KEY : ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY_PR }}
121
+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
122
+ # For jobs running on 'pull_request', tar and upload build scan data.
123
+ # The actual publishing must be done in a separate job (see ci-report.yml).
124
+ # We don't write to the remote cache as that would be unsafe.
125
+ - name : Tar build scan content pushed to subsequent jobs
126
+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }}"
127
+ run : tar -czf build-scan-data.tgz -C ~/.m2/.develocity/build-scan-data .
128
+ - name : Upload GitHub Actions artifact for the Develocity build scan
129
+ uses : actions/upload-artifact@v4
130
+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }}"
131
+ with :
132
+ name : build-scan-data-initial-${{ matrix.os.name }}
133
+ path : build-scan-data.tgz
145
134
146
135
- name : Run integration tests in the default environment
147
136
run : |
148
137
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \
149
138
-Pskip-checks \
150
139
${{ github.event.pull_request.base.ref && format('-Dincremental -Dgib.referenceBranch=refs/remotes/origin/{0}', github.event.pull_request.base.ref) || '' }}
151
140
env :
152
- # WARNING: exposes secrets, so must only be passed to a step that doesn't run unapproved code.
153
- DEVELOCITY_ACCESS_KEY : " ${{ github.event_name == 'push' && secrets.GRADLE_ENTERPRISE_ACCESS_KEY || '' }} "
154
- - name : Publish Develocity build scan for previous build (pull request)
155
- # Don't fail a build if publishing fails
156
- continue-on-error : true
157
- if : " ${{ !cancelled() && github.event_name == 'pull_request_target' && github.repository == 'hibernate/hibernate-search' }} "
158
- run : |
159
- ./mvnw $MAVEN_ARGS develocity:build-scan-publish-previous
160
- env :
161
- # WARNING: exposes secrets, so must only be passed to a step that doesn't run unapproved code.
162
- DEVELOCITY_ACCESS_KEY : ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY_PR }}
141
+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY || '' }} "
142
+ # Same as above, but for the build scan of the latest Maven run.
143
+ - name : Tar build scan content pushed to subsequent jobs
144
+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }} "
145
+ run : tar -czf build-scan-data.tgz -C ~/.m2/.develocity/build-scan-data .
146
+ - name : Upload GitHub Actions artifact for the Develocity build scan
147
+ uses : actions/upload-artifact@v4
148
+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }} "
149
+ with :
150
+ name : build-scan-data-integrationtest-${{ matrix.os.name }}
151
+ path : build-scan-data.tgz
163
152
164
153
- name : Docker cleanup
165
154
run : ./ci/docker-cleanup.sh
0 commit comments