File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -213,15 +213,22 @@ jobs:
213213 echo "inside pr_number=$PR_NUMBER"
214214 echo "Before pr_number=$PR_NUMBER"
215215
216- PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls?state=open"
216+ # Query all pull requests (open, closed, and merged)
217+ PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls"
217218 PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.v3+json" \
218219 -H "Authorization: Bearer $GITHUB_TOKEN" \
219220 $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
227+
220228 if [ -z "$PR_NUMBER" ]; then
221229 echo "No PR associated with this commit. Skipping deployment."
222230 exit 0
223231 fi
224- echo "PR_NUMBER=$PR_NUMBER"
225232
226233
227234
You can’t perform that action at this time.
0 commit comments