99# See https://docs.github.com/en/actions
1010# for more information about GitHub actions.
1111
12- name : GitHub Actions Build
12+ name : GH Actions CI
1313
1414on :
1515 push :
2424 - ' !wip/**/dependency-update/**'
2525 tags :
2626 - ' **'
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 :
3028 types : [opened, synchronize, reopened, ready_for_review]
3129 branches :
3230 # Pattern order matters: the last matching inclusion/exclusion wins
4442
4543concurrency :
4644 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' }}
4846
4947defaults :
5048 run :
9088 - name : Support longpaths on Windows
9189 if : " startsWith(matrix.os.runs-on, 'windows')"
9290 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
9992 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
10894 # Fetch the whole history to make sure that gitflow incremental builder
10995 # can find the base commit.
11096 fetch-depth : 0
@@ -118,9 +104,10 @@ jobs:
118104 uses : actions/cache@v4
119105 with :
120106 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') }}
122109 restore-keys : |
123- ${{ runner.os }}-maven-
110+ ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-
124111 - name : Set up Maven
125112 run : ./mvnw -v
126113 - name : Docker cleanup
@@ -131,35 +118,37 @@ jobs:
131118 ./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
132119 -Pjqassistant -Pdist -Pci-build -DskipITs
133120 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
145134
146135 - name : Run integration tests in the default environment
147136 run : |
148137 ./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \
149138 -Pskip-checks \
150139 ${{ github.event.pull_request.base.ref && format('-Dincremental -Dgib.referenceBranch=refs/remotes/origin/{0}', github.event.pull_request.base.ref) || '' }}
151140 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
163152
164153 - name : Docker cleanup
165154 run : ./ci/docker-cleanup.sh
0 commit comments