ops: workflow for trunk-based strategy (#94) #46
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: Deploy onboarding functions | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: [closed] | ||
paths: | ||
- "apps/onboarding-functions/**" | ||
- "apps/pom.xml" | ||
# deploy UAT when create a new branch release*, condition below contains() permit to execute worflow only for 'release' branch | ||
create: | ||
workflow_dispatch: | ||
inputs: | ||
environment: | ||
required: true | ||
type: choice | ||
description: Select the Environment | ||
options: | ||
- dev | ||
- uat | ||
- prod | ||
env: | ||
ENV_NAME: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'dev' || (contains(github.ref_name, 'release') && 'uat' || 'dev')) }}" | ||
jobs: | ||
build: | ||
name: Build Onboarding Functions | ||
runs-on: ubuntu-latest | ||
if: ${{ (github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true || contains(github.ref_name, 'release')) }} | ||
environment: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'dev' || (contains(github.ref_name, 'release') && 'uat' || 'dev')) }}-ci" | ||
permissions: | ||
packages: write | ||
contents: write | ||
id-token: write | ||
steps: | ||
- name: Setup Maven Action | ||
uses: s4u/setup-maven-action@fa2c7e4517ed008b1f73e7e0195a9eecf5582cd4 # pin@v1.11.0 | ||
with: | ||
checkout-fetch-depth: 0 | ||
checkout-ref: ${{ github.ref_name }} | ||
java-version: 17 | ||
java-distribution: 'temurin' | ||
maven-version: '3.9.5' | ||
cache-enabled: true | ||
- name: "Build Functions and dependencies" | ||
shell: bash | ||
run: mvn --projects :onboarding-functions --also-make package install -DskipTests | ||
-Dquarkus.azure-functions.app-name=${{ vars.AZURE_ONBOARDING_FN_APP_NAME }} | ||
- name: Log in to Azure | ||
uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 | ||
with: | ||
client-id: ${{ secrets.AZURE_CLIENT_ID_CD }} | ||
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
- name: "Deploy Functions" | ||
shell: bash | ||
run: mvn -f apps/onboarding-functions/pom.xml quarkus:deploy | ||
-Dquarkus.azure-functions.app-name=${{ vars.AZURE_ONBOARDING_FN_APP_NAME }} | ||
-Dquarkus.azure-functions.subscription-id=${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
-Dquarkus.azure-functions.resource-group=${{ vars.AZURE_ONBOARDING_FN_RESOURCE_GROUP }} | ||
-Dquarkus.azure-functions.region=westeurope | ||
-Dquarkus.azure-functions.app-service-plan-name=${{ vars.AZURE_ONBOARDING_FN_SERVICE_PLAN }} | ||
-Dquarkus.azure-functions.runtime.java-version=17 | ||