|
16 | 16 | env:
|
17 | 17 | HOTFIX_PR_AUTHOR: ${{ github.event.pull_request.user.login }}
|
18 | 18 | HOTFIX_PR_TITLE: ${{ github.event.pull_request.title }}
|
| 19 | + HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED: ${{ vars.HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED }} |
19 | 20 | steps:
|
20 | 21 | - name: Checkout repository
|
21 | 22 | uses: actions/checkout@v4
|
|
33 | 34 | # Extract a list of lines with the format 'juspay/hyperswitch/pull/1200' or '#1200' using 'sed'.
|
34 | 35 | # If empty, then error out and exit.
|
35 | 36 | # else, use 'grep' to extract out 'juspay/hyperswitch/pull/1200' or '#1200' patterns from each line.
|
36 |
| - # Use 'sed' to remove the part of the matched strings that precedes the last "/" character (in cases like, juspay/hyperswitch/pull/1200 - 1200) |
37 |
| - # and sed again to remove any "#" characters from the extracted numeric part (in cases like #1200 - 1200), ultimately getting PR/issue number. |
| 37 | + # Use 'sed' to remove the part of the matched strings that precedes the last "/" character (in cases like, juspay/hyperswitch/pull/1200 - 1200) |
| 38 | + # and sed again to remove any "#" characters from the extracted numeric part (in cases like #1200 - 1200), ultimately getting PR/issue number. |
38 | 39 | # Finally, remove (if any) duplicates from the list
|
39 | 40 |
|
40 | 41 | SED_OUTPUT=$(sed -E '/\/juspay\/hyperswitch\/pull\/[0-9]+|#[0-9]+/!d' hotfix_pr_body.txt)
|
@@ -73,10 +74,11 @@ jobs:
|
73 | 74 | pr_base_ref=$(echo "${pr_info}" | jq -r '.baseRefName')
|
74 | 75 | pr_state=$(echo "${pr_info}" | jq -r '.state')
|
75 | 76 |
|
76 |
| - if [[ "${pr_author}" == "${HOTFIX_PR_AUTHOR}" && \ |
77 |
| - "${pr_title}" == "${HOTFIX_PR_TITLE}" && \ |
78 |
| - "${pr_base_ref}" == "main" && \ |
79 |
| - "${pr_state}" == "MERGED" ]]; then |
| 77 | + if [[ "${pr_author}" == "${HOTFIX_PR_AUTHOR}" && |
| 78 | + "${pr_title}" == "${HOTFIX_PR_TITLE}" && |
| 79 | + "${pr_base_ref}" == "main" && |
| 80 | + (("${HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED}" == 'true' && "${pr_state}" == "MERGED") || |
| 81 | + ("${HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED}" != 'true')) ]]; then |
80 | 82 |
|
81 | 83 | all_checks_failed=0
|
82 | 84 | break
|
|
86 | 88 | PR_TITLES+=("$pr_title")
|
87 | 89 | PR_BASE_REFS+=("$pr_base_ref")
|
88 | 90 | PR_STATES+=("$pr_state")
|
89 |
| - |
90 | 91 | fi
|
91 | 92 | done
|
92 | 93 |
|
@@ -140,19 +141,21 @@ jobs:
|
140 | 141 | fi
|
141 | 142 |
|
142 | 143 |
|
143 |
| - # Set a flag to track if any of the original PR's state is 'MERGED' |
144 |
| - original_pr_merged=0 |
| 144 | + if [[ "${HOTFIX_PR_NEEDS_MAIN_BRANCH_PR_MERGED}" == 'true' ]]; then |
| 145 | + # Set a flag to track if any of the original PR's state is 'MERGED' |
| 146 | + original_pr_merged=0 |
145 | 147 |
|
146 |
| - for ((i = 0; i < ${#PR_STATES[@]}; i++)); do |
147 |
| - if [[ "${PR_STATES[i]}" == "MERGED" ]]; then |
148 |
| - # If a match is found, set the flag to 1 and break out of the loop |
149 |
| - original_pr_merged=1 |
150 |
| - break |
151 |
| - fi |
152 |
| - done |
| 148 | + for ((i = 0; i < ${#PR_STATES[@]}; i++)); do |
| 149 | + if [[ "${PR_STATES[i]}" == "MERGED" ]]; then |
| 150 | + # If a match is found, set the flag to 1 and break out of the loop |
| 151 | + original_pr_merged=1 |
| 152 | + break |
| 153 | + fi |
| 154 | + done |
153 | 155 |
|
154 |
| - if [[ $original_pr_merged -eq 0 ]]; then |
155 |
| - echo "::error::None of the Original PR is merged" |
| 156 | + if [[ $original_pr_merged -eq 0 ]]; then |
| 157 | + echo "::error::None of the Original PR is merged" |
| 158 | + fi |
156 | 159 | fi
|
157 | 160 |
|
158 | 161 | # Print all Original PR's (number), (pr_title), (pr_author), (pr_base_ref) and (pr_state)
|
|
0 commit comments