File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -212,11 +212,24 @@ jobs:
212212 run : |
213213 echo "inside pr_number=$PR_NUMBER"
214214 echo "Before pr_number=$PR_NUMBER"
215- PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
216- PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
215+
216+ PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls?state=open"
217+ PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.v3+json" \
217218 -H "Authorization: Bearer $GITHUB_TOKEN" \
218- $PR_API_URL | jq '.[0].number')
219- echo "after pr_number=$PR_NUMBER"
219+ $PR_API_URL | jq '.[] | select(.head.sha == "'${GITHUB_SHA}'") | .number')
220+ if [ -z "$PR_NUMBER" ]; then
221+ echo "No PR associated with this commit. Skipping deployment."
222+ exit 0
223+ fi
224+ echo "PR_NUMBER=$PR_NUMBER"
225+
226+
227+
228+ #PR_API_URL="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits/${GITHUB_SHA}/pulls"
229+ #PR_NUMBER=$(curl -s -H "Accept: application/vnd.github.groot-preview+json" \
230+ # -H "Authorization: Bearer $GITHUB_TOKEN" \
231+ # $PR_API_URL | jq '.[0].number')
232+ #echo "after pr_number=$PR_NUMBER"
220233 aws s3 sync s3://$S3_BUCKET_NAME/mergeRequest/$PR_NUMBER s3://$S3_BUCKET_NAME/production/
221234 echo "deploy complete to production !!!"
222235 # Delete contents of the pr folder
You can’t perform that action at this time.
0 commit comments