From 2e3fb4294ded2265e539d50d8e986ff4254cc523 Mon Sep 17 00:00:00 2001 From: nnh53 Date: Sat, 25 Nov 2023 21:06:41 +0700 Subject: [PATCH] Update gh action --- .github/workflows/enforcer.yml | 13 ++++++------- .github/workflows/hotfix-branch.yml | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/hotfix-branch.yml diff --git a/.github/workflows/enforcer.yml b/.github/workflows/enforcer.yml index cef4337..2a2694d 100644 --- a/.github/workflows/enforcer.yml +++ b/.github/workflows/enforcer.yml @@ -1,4 +1,4 @@ -name: Enforce branch rules +name: Enforce branch workflow on: pull_request: @@ -6,12 +6,11 @@ on: - main jobs: - check_branch_main: + job_enforce_main: runs-on: ubuntu-latest steps: - - name: Check Branch main + - name: Enforce main + if: github.base_ref == 'main' && !(startsWith(github.head_ref, 'develop') || startsWith(github.head_ref, 'hotfix/')) run: | - if [[ "${{ github.head_ref }}" != "develop" && ! "${{ github.head_ref }}" =~ ^hotfix/ ]]; then - echo "ERROR: You can only merge to main from develop or hotfix/*." - exit 1 - fi + echo "ERROR: You can only merge to main from develop or hotfix/**" + exit 1 diff --git a/.github/workflows/hotfix-branch.yml b/.github/workflows/hotfix-branch.yml new file mode 100644 index 0000000..895e87b --- /dev/null +++ b/.github/workflows/hotfix-branch.yml @@ -0,0 +1,21 @@ +name: Merge "hotfix/**" into "main" and "develop" + +on: + pull_request: + branches: + - hotfix/** + types: + - closed + +jobs: + merge_hotfix_into_main_and_develop: + runs-on: ubuntu-latest + steps: + - name: Merge hotfix into main and develop + run: | + git checkout main + git merge --no-ff origin/hotfix + git push origin main + git checkout develop + git merge --no-ff origin/hotfix + git push origin develop