Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

ci(hotfix-pr-check): conditionally enforce requirement of main branch PR being merged (#7351)

Sanchith Hegde122c35da0bda
diff --git a/.github/workflows/hotfix-pr-check.yml b/.github/workflows/hotfix-pr-check.yml
index cf7fc47b5b..e6da829edc 100644
--- a/.github/workflows/hotfix-pr-check.yml
+++ b/.github/workflows/hotfix-pr-check.yml
@@ -16,6 +16,7 @@ jobs:
env:
HOTFIX_PR_AUTHOR: ${{ github.event.pull_request.user.login }}
HOTFIX_PR_TITLE: ${{ github.event.pull_request.title }}
+ HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED: ${{ vars.HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -33,8 +34,8 @@ jobs:
# Extract a list of lines with the format 'juspay/hyperswitch/pull/1200' or '#1200' using 'sed'.
# If empty, then error out and exit.
# else, use 'grep' to extract out 'juspay/hyperswitch/pull/1200' or '#1200' patterns from each line.
- # Use 'sed' to remove the part of the matched strings that precedes the last "/" character (in cases like, juspay/hyperswitch/pull/1200 - 1200)
- # and sed again to remove any "#" characters from the extracted numeric part (in cases like #1200 - 1200), ultimately getting PR/issue number.
+ # Use 'sed' to remove the part of the matched strings that precedes the last "/" character (in cases like, juspay/hyperswitch/pull/1200 - 1200)
+ # and sed again to remove any "#" characters from the extracted numeric part (in cases like #1200 - 1200), ultimately getting PR/issue number.
# Finally, remove (if any) duplicates from the list
SED_OUTPUT=$(sed -E '/\/juspay\/hyperswitch\/pull\/[0-9]+|#[0-9]+/!d' hotfix_pr_body.txt)
@@ -73,10 +74,11 @@ jobs:
pr_base_ref=$(echo "${pr_info}" | jq -r '.baseRefName')
pr_state=$(echo "${pr_info}" | jq -r '.state')
- if [[ "${pr_author}" == "${HOTFIX_PR_AUTHOR}" && \
- "${pr_title}" == "${HOTFIX_PR_TITLE}" && \
- "${pr_base_ref}" == "main" && \
- "${pr_state}" == "MERGED" ]]; then
+ if [[ "${pr_author}" == "${HOTFIX_PR_AUTHOR}" &&
+ "${pr_title}" == "${HOTFIX_PR_TITLE}" &&
+ "${pr_base_ref}" == "main" &&
+ (("${HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED}" == 'true' && "${pr_state}" == "MERGED") ||
+ ("${HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED}" != 'true')) ]]; then
all_checks_failed=0
break
@@ -86,7 +88,6 @@ jobs:
PR_TITLES+=("$pr_title")
PR_BASE_REFS+=("$pr_base_ref")
PR_STATES+=("$pr_state")
-
fi
done
@@ -140,19 +141,21 @@ jobs:
fi
- # Set a flag to track if any of the original PR's state is 'MERGED'
- original_pr_merged=0
+ if [[ "${HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED}" == 'true' ]]; then
+ # Set a flag to track if any of the original PR's state is 'MERGED'
+ original_pr_merged=0
- for ((i = 0; i < ${#PR_STATES[@]}; i++)); do
- if [[ "${PR_STATES[i]}" == "MERGED" ]]; then
- # If a match is found, set the flag to 1 and break out of the loop
- original_pr_merged=1
- break
- fi
- done
+ for ((i = 0; i < ${#PR_STATES[@]}; i++)); do
+ if [[ "${PR_STATES[i]}" == "MERGED" ]]; then
+ # If a match is found, set the flag to 1 and break out of the loop
+ original_pr_merged=1
+ break
+ fi
+ done
- if [[ $original_pr_merged -eq 0 ]]; then
- echo "::error::None of the Original PR is merged"
+ if [[ $original_pr_merged -eq 0 ]]; then
+ echo "::error::None of the Original PR is merged"
+ fi
fi
# Print all Original PR's (number), (pr_title), (pr_author), (pr_base_ref) and (pr_state)