Skip to content

Commit

Permalink
minor CI fix to handle no PRs
Browse files Browse the repository at this point in the history
stop early if there are no pull requests (e.g. in case this is a fork)
  • Loading branch information
nyurik committed Apr 27, 2020
1 parent 75a4710 commit 921b307
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/pr-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,20 @@ jobs:
"$1"
}
# Get all open pull requests, most recently updated first
# (this way we don't need to page through all of them)
OPEN_PULL_REQUESTS="$(crl "$GITHUB_API/pulls?state=open&sort=updated&direction=desc")"
if [ $(jq 'length' <( echo "$OPEN_PULL_REQUESTS" ) ) -eq 0 ]; then
echo "There are no open pull requests. Exiting."
exit
fi
# Resolve workflow name into workflow ID
WORKFLOW_ID="$(crl "$GITHUB_API/actions/workflows" \
| jq ".workflows[] | select(.name == \"$WORKFLOW_NAME\") | .id")"
echo "WORKFLOW_NAME='$WORKFLOW_NAME' ==> WORKFLOW_ID=${WORKFLOW_ID}"
# Get all open pull requests, most recently updated first
# (this way we don't need to page through all of them)
OPEN_PULL_REQUESTS="$(crl "$GITHUB_API/pulls?state=open&sort=updated&direction=desc")"
# Get all workflow runs that were triggered by pull requests
WORKFLOW_PR_RUNS="$(crl "$GITHUB_API/actions/workflows/${WORKFLOW_ID}/runs?event=pull_request")"
Expand Down

0 comments on commit 921b307

Please sign in to comment.