Skip to content

Commit fcf8a5d

Browse files
authored
Merge pull request #82 from Code-dot-mil/hshah-mitre-patch-1
Update PR number retrieval in deploy workflow
2 parents c0d0fbb + fdeff15 commit fcf8a5d

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff 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

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ author: That Would Be Me
1010
# Dec 23 04:15 Updating this line
1111
# Dec 23 04:39 Updating this line
1212
# Dec 23 04:39 Updating this line
13-
# two
13+
# Dec 23 05:58 Updating this line
1414
# one
1515

1616
# Change seven 7

0 commit comments

Comments
 (0)