Skip to content

Commit 1b11cfb

Browse files
authored
Simplify PR number retrieval in deploy workflow
Removed redundant PR number retrieval logic and fallback mechanism.
1 parent 34886eb commit 1b11cfb

1 file changed

Lines changed: 6 additions & 24 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -211,32 +211,14 @@ jobs:
211211
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212212
run: |
213213
echo "inside pr_number=$PR_NUMBER"
214-
echo "Before pr_number=$PR_NUMBER"
215-
216-
# Query all pull requests (open, closed, and merged)
217-
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls"
218-
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.v3+json" \
219-
-H "Authorization: Bearer $GITHUB_TOKEN" \
220-
$PR_API_URL | jq '.[] | select(.head.sha == "'${GITHUB_SHA}'") | .number')
221-
222-
# Fallback: Retrieve PR number from GITHUB_EVENT_PATH if API fails
223-
if [ -z "$PR_NUMBER" ]; then
224-
echo "PR number not found via API. Attempting fallback..."
225-
PR_NUMBER=$(jq -r '.pull_request.number // empty' < "$GITHUB_EVENT_PATH")
226-
fi
214+
echo "Before pr_number=$PR_NUMBER"
227215
228-
if [ -z "$PR_NUMBER" ]; then
229-
echo "No PR associated with this commit. Skipping deployment."
230-
exit 0
231-
fi
232-
233-
216+
PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
217+
PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
218+
-H "Authorization: Bearer $GITHUB_TOKEN" \
219+
$PR_API_URL | jq '.[0].number')
220+
echo "after pr_number=$PR_NUMBER"
234221
235-
#PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
236-
#PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
237-
# -H "Authorization: Bearer $GITHUB_TOKEN" \
238-
# $PR_API_URL | jq '.[0].number')
239-
#echo "after pr_number=$PR_NUMBER"
240222
aws s3 sync s3://$S3_BUCKET_NAME/mergeRequest/$PR_NUMBER s3://$S3_BUCKET_NAME/production/
241223
echo "deploy complete to production !!!"
242224
# Delete contents of the pr folder

0 commit comments

Comments
 (0)