|
| 1 | +# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org> |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: MPL-2.0 |
| 4 | + |
| 5 | +name: Java CI with Gradle for library |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + workflow_dispatch: |
| 10 | + inputs: |
| 11 | + local_image_tag: |
| 12 | + description: Local image tag used before push |
| 13 | + required: false |
| 14 | + type: string |
| 15 | + default: application:0.0.1-SNAPSHOT |
| 16 | + deploy_branch: |
| 17 | + description: Branch required to push image |
| 18 | + required: false |
| 19 | + type: string |
| 20 | + default: main |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-and-test: |
| 28 | + name: Build & Test |
| 29 | + runs-on: ubuntu-latest |
| 30 | + permissions: |
| 31 | + id-token: write # Needed to load credentials |
| 32 | + contents: read # Needed to read repository (content) |
| 33 | + outputs: |
| 34 | + build_tag: ${{ steps.create_tag.outputs.build_tag }} |
| 35 | + environment: |
| 36 | + name: ci |
| 37 | + env: |
| 38 | + LOCAL_IMAGE_TAG: ${{ inputs.local_image_tag }} |
| 39 | + DEPLOY_BRANCH: ${{ inputs.deploy_branch }} |
| 40 | + IMAGE_REPOSITORY_PREFIX: ${{ inputs.image_repository_prefix }}${{ inputs.namespace }} |
| 41 | + IS_TAG: ${{ github.ref_type == 'tag' }} |
| 42 | + steps: |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # 7.0.1 |
| 45 | + with: |
| 46 | + fetch-depth: 1 |
| 47 | + persist-credentials: false |
| 48 | + |
| 49 | + - name: Setup runtime |
| 50 | + uses: ./.github/actions/setup-runtime |
| 51 | + |
| 52 | + - name: Cache Gradle |
| 53 | + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 #v6.1.0 |
| 54 | + with: |
| 55 | + path: | |
| 56 | + ~/.gradle/caches |
| 57 | + ~/.gradle/wrapper |
| 58 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/settings.gradle*') }} |
| 59 | + |
| 60 | + - name: Optimize Gradle |
| 61 | + shell: bash |
| 62 | + run: | |
| 63 | + mkdir -p ~/.gradle |
| 64 | + echo "org.gradle.caching=true" >> ~/.gradle/gradle.properties |
| 65 | + echo "org.gradle.configuration-cache=true" >> ~/.gradle/gradle.properties |
| 66 | +
|
| 67 | + - name: Build & Run Tests |
| 68 | + run: ./gradlew build --configuration-cache |
| 69 | + |
| 70 | + - name: Create Build Tag |
| 71 | + id: create_tag |
| 72 | + uses: ./.github/actions/create-build-tag |
| 73 | + |
| 74 | + - name: Repository Name |
| 75 | + id: repo |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + echo "name=${GITHUB_REPOSITORY#*/}" >> "$GITHUB_OUTPUT" |
0 commit comments