cicd: Add output cache-key #TASK-7809 #1
This file contains hidden or 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: Reusable workflow to build Java application | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| maven_opts: | ||
| type: string | ||
| required: false | ||
| build_folder: | ||
| type: string | ||
| required: false | ||
| default: "build-folder" | ||
| upload-artifact: | ||
| type: boolean | ||
| required: false | ||
| default: true | ||
| needs_hadoop_preparation: | ||
| type: boolean | ||
| required: false | ||
| default: false | ||
| hadoop_flavour: | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| outputs: | ||
| version: | ||
| description: "Project version" | ||
| value: ${{ jobs.build-workflow.outputs.version }} | ||
| jobs: | ||
| build-workflow: | ||
| name: Build Java app | ||
| runs-on: ${{ vars.UBUNTU_VERSION }} | ||
| outputs: | ||
| version: ${{ steps.get_project_version.outputs.version }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: '10' | ||
| - name: Set up JDK 8 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '8' | ||
| cache: 'maven' | ||
| - name: Cache local Maven repository | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.m2/repository | ||
| key: ${{ runner.os }}-maven-${{ inputs.hadoop_flavour || vars.HADOOP_FLAVOUR }}-${{ github.sha }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-maven-${{ inputs.hadoop_flavour || vars.HADOOP_FLAVOUR }}- | ||
| - name: Install dependencies branches | ||
| run: | | ||
| if [ -f "./.github/workflows/scripts/get_same_branch.sh" ]; then | ||
| chmod +x ./.github/workflows/scripts/get_same_branch.sh | ||
| ./.github/workflows/scripts/get_same_branch.sh ${{ github.ref_name }} | ||
| fi | ||
| - name: Prepare Hadoop profile | ||
| if: ${{ inputs.needs_hadoop_preparation == true }} | ||
| run: | | ||
| chmod +x ./.github/workflows/scripts/prepare_hadoop.sh | ||
| ./.github/workflows/scripts/prepare_hadoop.sh --hadoop-flavour "${{ inputs.hadoop_flavour || vars.HADOOP_FLAVOUR }}" | ||
| env: | ||
| THIRDPARTY_READ_TOKEN: ${{ secrets.THIRDPARTY_READ_TOKEN }} | ||
| - name: Maven Build (skip tests) | ||
| run: mvn -T 2 clean install -DskipTests ${{ inputs.maven_opts }} --no-transfer-progress | ||
| - uses: actions/upload-artifact@v4 | ||
| if: ${{ inputs.upload-artifact == true }} | ||
| with: | ||
| name: ${{ inputs.build_folder }} | ||
| path: build | ||
| - id: get_project_version | ||
| name: Get project version | ||
| run: | | ||
| echo "version=`mvn help:evaluate -q -Dexpression=project.version -DforceStdout`" >> $GITHUB_OUTPUT | ||
| - name: test-version-from-check | ||
| run: echo "Project version is " ${{ steps.get_project_version.outputs.version }} | ||
| outputs: | ||
| cache-key: | ||
| description: "The key of the maven cache created" | ||
| value: ${{ jobs.build-workflow.steps.cache-local-maven-repository.outputs.cache-hit-key }} | ||