name: reusable-gradle # One place that knows how a Gradle job starts. # # Every job in this repository opened with the same preamble: checkout, a three-line pinned # wrapper-validation step, then the JDK/cache action. The wrapper step is gone (setup-gradle # validates wrappers itself), and this workflow removes the rest of the repetition for the jobs whose # only variation is the Gradle command they run. # # Jobs that need service containers, a matrix, artifact uploads or per-job env stay written out with # `./.github/actions/setup-gradle-java`, because expressing those through `workflow_call` inputs # means encoding YAML inside strings — which is how a "shared" workflow becomes less readable than # the duplication it replaced. on: workflow_call: inputs: tasks: description: The Gradle task list, whitespace-separated. required: true type: string gradle-args: description: Flags appended after the task list. required: false type: string default: "--no-daemon --stacktrace" working-directory: description: Directory the wrapper is invoked from. required: false type: string default: src timeout-minutes: required: false type: number default: 30 continue-on-error: description: Run the job as an advisory signal rather than a gate. required: false type: boolean default: false permissions: contents: read jobs: gradle: runs-on: ubuntu-latest timeout-minutes: ${{ inputs.timeout-minutes }} continue-on-error: ${{ inputs.continue-on-error }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 - uses: ./.github/actions/setup-gradle-java - name: Run ${{ inputs.tasks }} working-directory: ${{ inputs.working-directory }} env: GRADLE_TASKS: ${{ inputs.tasks }} GRADLE_ARGS: ${{ inputs.gradle-args }} run: | set -euo pipefail # Word-split on purpose: both inputs are task/flag lists. They come from this repository's # own workflow files, never from a pull request. # shellcheck disable=SC2086 ./gradlew ${GRADLE_TASKS} ${GRADLE_ARGS}