Skip to content

Commit

Permalink
second commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Chethan-rao committed Mar 20, 2024
1 parent cf83ab9 commit 9d42f30
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@ jobs:
runs-on: ubuntu-latest
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 +59,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 +71,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}" == '${{ github.event.pull_request.title }}' && \
"${pr_base_ref}" == "master" && \
"${pr_state}" == "MERGED" ]]; then
Expand Down Expand Up @@ -108,15 +109,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 [[ '${{github.event.pull_request.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: '${{ github.event.pull_request.title }}'
fi
Expand All @@ -132,7 +133,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

0 comments on commit 9d42f30

Please sign in to comment.