-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use `pull_request` instead of `pull_request_target` * Move Develocity build scan publishing for untrusted code to a separate workflow * Split caches between trusted and untrusted code * Update secrets to use "Develocity" name instead of "Gradle Enterprise" Co-Authored-By: Christian Beikov <[email protected]>
- Loading branch information
Showing
2 changed files
with
101 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: GH Actions CI reporting | ||
|
||
on: | ||
workflow_run: | ||
workflows: [ "GH Actions CI" ] | ||
types: [ completed ] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end" | ||
|
||
jobs: | ||
publish-build-scans: | ||
name: Publish Develocity build scans | ||
if: github.repository == 'hibernate/hibernate-search' && github.event.workflow_run.conclusion != 'cancelled' | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Checkout target branch which has trusted code | ||
- name: Check out target branch | ||
uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
ref: ${{ github.ref }} | ||
- name: Set up Java ${{ matrix.os.java.version }} | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: ${{ matrix.os.java.version }} | ||
distribution: temurin | ||
# https://github.com/actions/cache/blob/main/examples.md#java---maven | ||
- name: Cache local Maven repository | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2/repository | ||
# use a different key than workflows running untrusted code | ||
key: trusted-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
trusted-${{ runner.os }}-maven- | ||
- name: Set up Maven | ||
run: ./mvnw -v | ||
- name: Download GitHub Actions artifacts for the Develocity build scans | ||
id: downloadBuildScan | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: build-scan-data-${{ matrix.rdbms }} | ||
github-token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
path: /tmp/downloaded-build-scan-data/ | ||
pattern: build-scan-data-* | ||
# Don't fail the build if there are no matching artifacts | ||
continue-on-error: true | ||
- name: Publish Develocity build scans for previous builds | ||
if: ${{ steps.downloadBuildScan.outcome != 'failure'}} | ||
run: | | ||
shopt -s nullglob # Don't run the loop below if there are no artifacts | ||
status=0 | ||
for build_scan_data_directory in /tmp/downloaded-build-scan-data/* | ||
do | ||
rm -rf ~/.gradle/build-scan-data | ||
mkdir -p ~/.gradle/build-scan-data | ||
tar -xzf "$build_scan_data_directory/build-scan-data.tgz" -C ~/.gradle/build-scan-data \ | ||
&& ./mvnw $MAVEN_ARGS develocity:build-scan-publish-previous || status=1 | ||
done | ||
exit $status | ||
env: | ||
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY_PR }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters