chore: fix 2 pmd errors blocking pipeline #6
Workflow file for this run
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: CI Build and Publish | ||
| on: | ||
| workflow_call: | ||
| env: | ||
| AZURE_STORAGE_CONNECTION_STRING: ${{ vars.AZURE_STORAGE_CONNECTION_STRING }} | ||
| secrets: | ||
| AZURE_DEVOPS_ARTIFACT_USERNAME: | ||
| required: true | ||
| AZURE_DEVOPS_ARTIFACT_TOKEN: | ||
| required: true | ||
| HMCTS_ADO_PAT: | ||
| required: true | ||
| inputs: | ||
| is_release: | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| is_publish: | ||
| required: true | ||
| type: boolean | ||
| trigger_docker: | ||
| required: true | ||
| type: boolean | ||
| trigger_deploy: | ||
| required: true | ||
| type: boolean | ||
| jobs: | ||
| Artefact-Version: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| artefact_version: ${{ inputs.is_release && steps.artefact.outputs.release_version || steps.artefact.outputs.draft_version }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Generate Artefact Version | ||
| id: artefact | ||
| uses: hmcts/artefact-version-action@v1 | ||
| with: | ||
| release: ${{ inputs.is_release }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| Build: | ||
| needs: [Artefact-Version] | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| repo_name: ${{ steps.repo_vars.outputs.repo_name }} | ||
| artefact_name: ${{ steps.repo_vars.outputs.artefact_name }} | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v6 | ||
| - name: Set up JDK | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
| - name: Set up Gradle | ||
| uses: gradle/actions/setup-gradle@v5 | ||
| with: | ||
| gradle-version: current | ||
| - name: Gradle Build | ||
| env: | ||
| ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }} | ||
| run: | | ||
| echo "Building with ARTEFACT_VERSION=$ARTEFACT_VERSION" | ||
| ./gradlew build -DARTEFACT_VERSION=$ARTEFACT_VERSION | ||
| - name: Extract repo name | ||
| id: repo_vars | ||
| run: | | ||
| repo_name=${GITHUB_REPOSITORY##*/} | ||
| echo "repo_name=${repo_name}" >> $GITHUB_OUTPUT | ||
| echo "artefact_name=${repo_name}-${{ needs.Artefact-Version.outputs.artefact_version }}" >> $GITHUB_OUTPUT | ||
| - name: Upload JAR Artefact | ||
| uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: app-jar | ||
| path: build/libs/${{ steps.repo_vars.outputs.artefact_name }}.jar | ||
| Provider-Deploy: | ||
| needs: [ Artefact-Version, Build ] | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v6 | ||
| - name: Set up JDK | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '21' | ||
| - name: Set up Gradle | ||
| uses: gradle/actions/setup-gradle@v5 | ||
| with: | ||
| gradle-version: current | ||
| - name: Gradle Publish | ||
| if: ${{ inputs.is_publish }} | ||
| env: | ||
| ARTEFACT_VERSION: ${{ needs.Artefact-Version.outputs.artefact_version }} | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| AZURE_DEVOPS_ARTIFACT_USERNAME: ${{ secrets.AZURE_DEVOPS_ARTIFACT_USERNAME }} | ||
| AZURE_DEVOPS_ARTIFACT_TOKEN: ${{ secrets.AZURE_DEVOPS_ARTIFACT_TOKEN }} | ||
| run: | | ||
| if [ -z "AZURE_DEVOPS_ARTIFACT_USERNAME" ]; then | ||
| echo "::warning::AZURE_DEVOPS_ARTIFACT_USERNAME is null or not set" | ||
| fi | ||
| if [ -z "$AZURE_DEVOPS_ARTIFACT_TOKEN" ]; then | ||
| echo "::warning::AZURE_DEVOPS_ARTIFACT_TOKEN is null or not set" | ||
| fi | ||
| echo "Publishing artefact for version: $ARTEFACT_VERSION" | ||
| ./gradlew publish \ | ||
| -DARTEFACT_VERSION=$ARTEFACT_VERSION \ | ||
| -DGITHUB_REPOSITORY=${{ github.repository }} \ | ||
| -DGITHUB_ACTOR=${{ github.actor }} \ | ||
| -DGITHUB_TOKEN=$GITHUB_TOKEN \ | ||
| -DAZURE_DEVOPS_ARTIFACT_USERNAME=$AZURE_DEVOPS_ARTIFACT_USERNAME \ | ||
| -DAZURE_DEVOPS_ARTIFACT_TOKEN=$AZURE_DEVOPS_ARTIFACT_TOKEN | ||
| Deploy: | ||
| needs: [ Provider-Deploy, Build, Artefact-Version ] | ||
| if: ${{ inputs.trigger_deploy }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Extract repo name | ||
| run: echo "REPO_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV | ||
| - name: Trigger ADO pipeline | ||
| uses: hmcts/trigger-ado-pipeline@v1 | ||
| with: | ||
| pipeline_id: 460 | ||
| ado_pat: ${{ secrets.HMCTS_ADO_PAT }} | ||
| template_parameters: > | ||
| { | ||
| "GROUP_ID": "uk.gov.hmcts.cp", | ||
| "ARTIFACT_ID": "${{ env.REPO_NAME }}", | ||
| "ARTIFACT_VERSION": "${{ needs.Artefact-Version.outputs.artefact_version }}", | ||
| "TARGET_REPOSITORY": "${{ github.repository }}" | ||
| } | ||