From 8be60f6e424403bb6a83c52a5e7dcdac7b503c14 Mon Sep 17 00:00:00 2001 From: John Kasper Svergja Date: Tue, 16 Jan 2024 09:26:57 +0100 Subject: [PATCH] Add deploy java github action Internal ref: [DPSKY-173] Same as for ssb-datadoc-model --- .github/workflows/build-java.yml | 52 ++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/build-java.yml diff --git a/.github/workflows/build-java.yml b/.github/workflows/build-java.yml new file mode 100644 index 0000000..a2817fe --- /dev/null +++ b/.github/workflows/build-java.yml @@ -0,0 +1,52 @@ +name: Build Java + +on: + push: + branches: + - main + paths: + - "generated/java/**" + - ".github/workflows/build-java.yml" + pull_request: + branches: + - main + paths: + - "generated/java/**" + - ".github/workflows/build-java.yml" + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: zulu + + - name: Authenticate to Google Cloud + id: auth + uses: google-github-actions/auth@v2.0.1 + with: + workload_identity_provider: "projects/${{ secrets.GAR_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/gh-actions/providers/gh-actions" + service_account: "gh-actions-dapla-stat@${{ secrets.GAR_PROJECT_ID }}.iam.gserviceaccount.com" + token_format: access_token + + - name: Cache Maven packages + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build with Maven and deploy to Artifact Registry + run: | + pushd generated/java/dapla-kuben-resource-model + ./mvnw --batch-mode -P ssb deploy +