Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@ jobs:
hotfix_pr_check:
name: Verify Hotfix PR
runs-on: ubuntu-latest
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Get hotfix pull request body
shell: bash
run: |
echo '${{ github.event.pull_request.body }}' > hotfix_pr_body.txt
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: echo $PR_BODY > hotfix_pr_body.txt

- name: Get a list of all original PR numbers
shell: bash
run: |

# Extract a list of lines with the format 'juspay/hyperswitch-cloud/pull/1200' or '#1200' using 'sed'.
# 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-cloud/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-cloud/pull/1200 - 1200)
# 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.
# Finally, remove (if any) duplicates from the list

Expand Down Expand Up @@ -58,7 +61,7 @@ jobs:
PR_STATES=()

for pr_number in ${PR_NUMBERS}; do
is_pull_request="$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" "/repos/juspay/hyperswitch-cloud/issues/${pr_number}" | jq '.pull_request')"
is_pull_request="abc"

if [[ "$is_pull_request" == null ]]; then
continue
Expand All @@ -70,7 +73,7 @@ jobs:
pr_state=$(echo "${pr_info}" | jq -r '.state')

if [[ "${pr_author}" == "${{ github.event.pull_request.user.login }}" && \
"${pr_title}" == "${{ github.event.pull_request.title }}" && \
"${pr_title}" == "${PR_TITLE}" && \
"${pr_base_ref}" == "master" && \
"${pr_state}" == "MERGED" ]]; then

Expand Down Expand Up @@ -108,15 +111,15 @@ jobs:
title_match_found=0

for ((i = 0; i < ${#PR_TITLES[@]}; i++)); do
if [[ "${{github.event.pull_request.title}}" == "${PR_TITLES[i]}" ]]; then
if [[ "${PR_TITLE}" == "${PR_TITLES[i]}" ]]; then
# If a match is found, set the flag to 1 and break out of the loop
title_match_found=1
break
fi
done

if [[ $title_match_found -eq 0 ]]; then
echo "::error::Hotfix PR title does not match any of the Original PR titles. Hotfix PR title: '${{ github.event.pull_request.title }}'"
echo "::error::Hotfix PR title does not match any of the Original PR titles. Hotfix PR title: '${PR_TITLE}'"
fi


Expand All @@ -132,7 +135,7 @@ jobs:
done

if [[ $original_pr_points_to_main -eq 0 ]]; then
echo "::error::None of the Original PR's baseRef is 'main'"
echo "::error::None of the Original PR's baseRef is 'master'"
fi


Expand Down
Loading