vaas-java-ci #340
This file contains 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: vaas-java-ci | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "java/**" | |
- ".github/workflows/ci-java.yaml" | |
tags: | |
- "java*" | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "java/**" | |
- ".github/workflows/ci-java.yaml" | |
workflow_dispatch: | |
inputs: | |
environment: | |
type: choice | |
description: "Test environment" | |
options: | |
- production | |
- staging | |
default: "production" | |
env: | |
CLIENT_ID: ${{ secrets.CLIENT_ID }} | |
CLIENT_SECRET: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && secrets.CLIENT_SECRET || secrets.STAGING_CLIENT_SECRET }} | |
VAAS_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && 'wss://gateway.production.vaas.gdatasecurity.de' || 'wss://gateway.staging.vaas.gdatasecurity.de' }} | |
TOKEN_URL: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && 'https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token' || 'https://account-staging.gdata.de/realms/vaas-staging/protocol/openid-connect/token' }} | |
VAAS_CLIENT_ID: ${{ secrets.VAAS_CLIENT_ID }} | |
VAAS_USER_NAME: ${{ secrets.VAAS_USER_NAME }} | |
VAAS_PASSWORD: ${{ (inputs.environment == 'production' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/java')) && secrets.VAAS_PASSWORD || secrets.STAGING_VAAS_PASSWORD }} | |
jobs: | |
build-java: | |
name: Build & Test Java SDK | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: install Java | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "17" | |
distribution: "adopt" | |
- name: setup Gradle | |
uses: gradle/gradle-build-action@v2 | |
with: | |
gradle-version: "8.1" | |
- name: run tests | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: test | |
gradle-version: "8.1" | |
build-root-directory: java | |
- name: run examples for file | |
env: | |
SCAN_PATH: "src/main/java/de/gdata/vaasexample/Main.java" | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: fileScan | |
gradle-version: "8.1" | |
build-root-directory: java/examples/VaasExample | |
- name: run examples for url | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: urlScan | |
gradle-version: "8.1" | |
build-root-directory: java/examples/VaasExample | |
- name: extract version | |
if: startsWith(github.ref, 'refs/tags/java') | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/java}" >> $GITHUB_ENV | |
echo $RELEASE_VERSION | |
- name: set version | |
if: startsWith(github.ref, 'refs/tags/java') | |
run: | | |
sed -i "s/version = '0\.0\.0'/version = '$RELEASE_VERSION'/g" ./java/build.gradle | |
- name: publish Maven package | |
if: startsWith(github.ref, 'refs/tags/java') | |
env: | |
ORG_GRADLE_PROJECT_username: ${{ secrets.ORG_GRADLE_PROJECT_USERNAME }} | |
ORG_GRADLE_PROJECT_password: ${{ secrets.ORG_GRADLE_PROJECT_PASSWORD }} | |
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} | |
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publish | |
gradle-version: "8.1" | |
build-root-directory: java | |
- name: push to Maven Central | |
if: startsWith(github.ref, 'refs/tags/java') | |
env: | |
ORG_GRADLE_PROJECT_username: ${{ secrets.ORG_GRADLE_PROJECT_USERNAME }} | |
ORG_GRADLE_PROJECT_password: ${{ secrets.ORG_GRADLE_PROJECT_PASSWORD }} | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: closeAndReleaseRepository | |
gradle-version: "8.1" | |
build-root-directory: java | |
- name: Microsoft Teams Notification | |
uses: skitionek/notify-microsoft-teams@master | |
if: failure() | |
with: | |
webhook_url: ${{ secrets.MSTEAMS_WEBHOOK }} | |
overwrite: "{title: `Failed workflow on for VaaS-SDK ${workflow}`, sections: [{activityTitle: 'build failed', activitySubtitle: `Failed workflow on for VaaS-SDK ${workflow}`, activityImage: 'https://adaptivecards.io/content/cats/3.png'}], themeColor: '#ff0000'}" |