GH Actions CI reporting #1
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
name: GH Actions CI reporting | |
on: | |
workflow_run: | |
workflows: [ "GH Actions CI" ] | |
types: [ completed ] | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
publish-build-scans: | |
name: Publish Develocity build scans | |
if: github.repository == 'hibernate/hibernate-orm' && 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 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Generate cache key | |
id: cache-key | |
run: | | |
CURRENT_BRANCH="${{ github.repository != 'hibernate/hibernate-orm' && 'fork' || github.base_ref || github.ref_name }}" | |
CURRENT_MONTH=$(/bin/date -u "+%Y-%m") | |
CURRENT_DAY=$(/bin/date -u "+%d") | |
ROOT_CACHE_KEY="buildtool-cache" | |
echo "buildtool-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT | |
echo "buildtool-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT | |
echo "buildtool-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT | |
- name: Restore Maven/Gradle Dependency/Dist Caches | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
~/.m2/repository/ | |
~/.m2/wrapper/ | |
~/.gradle/caches/modules-2 | |
~/.gradle/wrapper/ | |
key: ${{ steps.cache-key.outputs.buildtool-cache-key }} | |
restore-keys: | | |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}- | |
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}- | |
- name: Download GitHub Actions artifacts for the Develocity build scans | |
id: downloadBuildScan | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: build-scan-data-* | |
github-token: ${{ github.token }} | |
repository: ${{ github.repository }} | |
run-id: ${{ github.event.workflow_run.id }} | |
path: /tmp/downloaded-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 \ | |
&& ./gradlew --no-build-cache buildScanPublishPrevious || status=1 | |
done | |
exit $status | |
env: | |
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY_PR }} |