From ee4e627d2b9ceb5497f9eef7301423c12bbcdd6d Mon Sep 17 00:00:00 2001 From: Manuel Rafeli Date: Thu, 18 Jan 2024 18:37:41 +0100 Subject: [PATCH] ops: workflow for trunk-based strategy (#94) * add on create deploy ms * test * test * test * test * test * fix test * test * test * containes * deploy functions * remove auto assigne * remove develop reference * fix check_pr --- .github/auto_assign.yml | 3 --- .github/workflows/check_pr.yml | 4 ++-- .github/workflows/code_review_functions.yml | 1 - .github/workflows/code_review_libs.yml | 1 - .github/workflows/code_review_ms.yml | 1 - .github/workflows/deploy_onboarding_functions.yml | 11 ++++++----- .github/workflows/deploy_onboarding_ms.yml | 9 +++++---- 7 files changed, 13 insertions(+), 17 deletions(-) delete mode 100644 .github/auto_assign.yml diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml deleted file mode 100644 index 2e0bbe214..000000000 --- a/.github/auto_assign.yml +++ /dev/null @@ -1,3 +0,0 @@ -addAssignees: author - -runOnDraft: true diff --git a/.github/workflows/check_pr.yml b/.github/workflows/check_pr.yml index f591e94d2..5a770e7d4 100644 --- a/.github/workflows/check_pr.yml +++ b/.github/workflows/check_pr.yml @@ -4,7 +4,7 @@ name: Check PR on: pull_request: branches: - - develop + - main types: - opened - synchronize @@ -33,7 +33,7 @@ jobs: - name: Get total lines changed run: | - size=$(git diff --stat origin/develop --diff-filter=d \ + size=$(git diff --stat origin/main --diff-filter=d \ | grep -v .lock \ | awk -F"|" '{ print $2 }' \ | awk '{ print $1 }' \ diff --git a/.github/workflows/code_review_functions.yml b/.github/workflows/code_review_functions.yml index 8eb910598..25ef749bd 100644 --- a/.github/workflows/code_review_functions.yml +++ b/.github/workflows/code_review_functions.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - main - - develop types: - opened - synchronize diff --git a/.github/workflows/code_review_libs.yml b/.github/workflows/code_review_libs.yml index 898374161..2e114d5e9 100644 --- a/.github/workflows/code_review_libs.yml +++ b/.github/workflows/code_review_libs.yml @@ -4,7 +4,6 @@ on: pull_request: branches: - main - - develop types: - opened - synchronize diff --git a/.github/workflows/code_review_ms.yml b/.github/workflows/code_review_ms.yml index ebe33e844..fdb049292 100644 --- a/.github/workflows/code_review_ms.yml +++ b/.github/workflows/code_review_ms.yml @@ -5,7 +5,6 @@ on: pull_request: branches: - main - - develop types: - opened - synchronize diff --git a/.github/workflows/deploy_onboarding_functions.yml b/.github/workflows/deploy_onboarding_functions.yml index 7abc6dcb9..04212f282 100644 --- a/.github/workflows/deploy_onboarding_functions.yml +++ b/.github/workflows/deploy_onboarding_functions.yml @@ -3,12 +3,13 @@ name: Deploy onboarding functions on: pull_request: branches: - - develop - main types: [closed] paths: - "apps/onboarding-functions/**" - - "apps/pom.xml" + - "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: @@ -22,14 +23,14 @@ on: - prod env: - ENV_NAME: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'prod' || (github.base_ref == 'develop' && 'uat' || 'dev')) }}" + 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) }} - environment: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'prod' || (github.base_ref == 'develop' && 'uat' || 'dev')) }}-cd" + 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 diff --git a/.github/workflows/deploy_onboarding_ms.yml b/.github/workflows/deploy_onboarding_ms.yml index 29798f37f..f3b5eff41 100644 --- a/.github/workflows/deploy_onboarding_ms.yml +++ b/.github/workflows/deploy_onboarding_ms.yml @@ -3,12 +3,13 @@ name: Deploy onboarding ms on: pull_request: branches: - - develop - main types: [closed] paths: - "apps/onboarding-ms/**" - "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: @@ -28,14 +29,14 @@ env: # started workflows, it picks up the value coming from the UI; otherwise, # it sets prod or uat depending on the current branch. # Ternary operator is not supported - ENV_NAME: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'prod' || (github.base_ref == 'develop' && 'uat' || 'dev')) }}" + ENV_NAME: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'dev' || (contains(github.ref_name, 'release') && 'uat' || 'dev')) }}" jobs: build: name: Build Onboarding Microservice runs-on: ubuntu-latest - if: ${{ (github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true) }} - environment: "${{ inputs.environment != null && inputs.environment || (github.base_ref == 'main' && 'prod' || (github.base_ref == 'develop' && 'uat' || 'dev')) }}-ci" + 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" outputs: environment: ${{ steps.setenv.outputs.environment }} short_sha: ${{ steps.setsha.outputs.short_sha }}