Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

ci: Extract Gradle cache priming into a reusable workflow (#7572)

Ludycb0cafabd925
diff --git a/.github/config/.files.yaml b/.github/config/.files.yaml
index 7804506535..7936145677 100644
--- a/.github/config/.files.yaml
+++ b/.github/config/.files.yaml
@@ -4,6 +4,7 @@
# instead of matching only the project filter.
ci: &ci
- .github/workflows/build.yml
+ - .github/workflows/gradle-cache-prime.yml
- .github/config/.files.yaml
build: &build
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 631102bf9a..d35b2ee177 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -62,62 +62,9 @@ jobs:
filters: .github/config/.files.yaml
gradle-cache-prime:
- environment:
- name: ci-unsigned
- deployment: false
- name: Prime shared Gradle cache
- if: needs.files-changed.outputs.project == 'true'
needs: [files-changed]
- runs-on: ubuntu-latest
- timeout-minutes: 15
- steps:
- - name: Harden the runner (Audit all outbound calls)
- uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
- with:
- egress-policy: audit
- - name: Checkout repository
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
-
- - name: Calculate Gradle cache key
- id: gradle-cache-key
- shell: bash
- run: |
- echo "key=gradle-v1-${{ runner.os }}-${{ runner.arch }}-jdk-25-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/libs.versions.toml', 'buildSrc/**', 'settings.gradle', 'build.gradle', 'app/**/build.gradle', 'gradle/**/*.gradle') }}" >> "$GITHUB_OUTPUT"
-
- - name: Cache Gradle (lookup-only)
- id: cache-gradle-restore
- uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ steps.gradle-cache-key.outputs.key }}
- lookup-only: true
-
- - name: Set up JDK 25
- if: steps.cache-gradle-restore.outputs.cache-hit != 'true'
- uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
- with:
- java-version: "25"
- distribution: "temurin"
-
- - name: Resolve backend dependencies
- if: steps.cache-gradle-restore.outputs.cache-hit != 'true'
- run: ./gradlew :stirling-pdf:classes --no-daemon
- env:
- STIRLING_FLAVOR: saas
- MAVEN_USER: ${{ secrets.MAVEN_USER }}
- MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
- MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
-
- - name: Save cache Gradle User Home
- if: steps.cache-gradle-restore.outputs.cache-hit != 'true'
- uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
- with:
- path: |
- ~/.gradle/caches
- ~/.gradle/wrapper
- key: ${{ steps.gradle-cache-key.outputs.key }}
+ uses: ./.github/workflows/gradle-cache-prime.yml
+ secrets: inherit
build:
if: needs.files-changed.outputs.backend == 'true'
diff --git a/.github/workflows/gradle-cache-prime.yml b/.github/workflows/gradle-cache-prime.yml
new file mode 100644
index 0000000000..b3700d8ac0
--- /dev/null
+++ b/.github/workflows/gradle-cache-prime.yml
@@ -0,0 +1,66 @@
+name: Prime Gradle Cache
+
+on:
+ workflow_call:
+ push:
+ branches: ["main"]
+
+permissions:
+ contents: read
+
+jobs:
+ gradle-cache-prime:
+ environment:
+ name: ci-unsigned
+ deployment: false
+ name: Prime shared Gradle cache
+ runs-on: ubuntu-latest
+ timeout-minutes: 15
+ steps:
+ - name: Harden the runner (Audit all outbound calls)
+ uses: step-security/harden-runner@b09bb98e06d4d774595224525879c09bc6e98c40 # v2.20.1
+ with:
+ egress-policy: audit
+ - name: Checkout repository
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+
+ - name: Calculate Gradle cache key
+ id: gradle-cache-key
+ shell: bash
+ run: |
+ echo "key=gradle-v1-${{ runner.os }}-${{ runner.arch }}-jdk-25-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/libs.versions.toml', 'buildSrc/**', 'settings.gradle', 'build.gradle', 'app/**/build.gradle', 'gradle/**/*.gradle') }}" >> "$GITHUB_OUTPUT"
+
+ - name: Cache Gradle (lookup-only)
+ id: cache-gradle-restore
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ steps.gradle-cache-key.outputs.key }}
+ lookup-only: true
+
+ - name: Set up JDK 25
+ if: steps.cache-gradle-restore.outputs.cache-hit != 'true'
+ uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
+ with:
+ java-version: "25"
+ distribution: "temurin"
+
+ - name: Resolve backend dependencies
+ if: steps.cache-gradle-restore.outputs.cache-hit != 'true'
+ run: ./gradlew :stirling-pdf:classes --no-daemon
+ env:
+ STIRLING_FLAVOR: saas
+ MAVEN_USER: ${{ secrets.MAVEN_USER }}
+ MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
+ MAVEN_PUBLIC_URL: ${{ secrets.MAVEN_PUBLIC_URL }}
+
+ - name: Save cache Gradle User Home
+ if: steps.cache-gradle-restore.outputs.cache-hit != 'true'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ steps.gradle-cache-key.outputs.key }}