Skip to content

Commit

Permalink
Allow PR_NUMBER to be set externally (cirrus-actions#76)
Browse files Browse the repository at this point in the history
(cherry picked from commit 9d21e09)
  • Loading branch information
pezholio authored and xzile committed Apr 19, 2022
1 parent 3b74f11 commit 3bae84f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ Example
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
```

You can also optionally specify the PR number of the branch to rebase,
if the action you're running doesn't directly refer to a specific
pull request:

```yaml
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.4
env:
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
PR_NUMBER: 1245
```


## Restricting who can call the action
Expand Down
17 changes: 10 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

set -e

PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH")
if [[ "$PR_NUMBER" == "null" ]]; then
PR_NUMBER=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
fi
if [[ "$PR_NUMBER" == "null" ]]; then
echo "Failed to determine PR Number."
exit 1
if [ -z "$PR_NUMBER" ]; then
PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH")
if [[ "$PR_NUMBER" == "null" ]]; then
PR_NUMBER=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
fi
if [[ "$PR_NUMBER" == "null" ]]; then
echo "Failed to determine PR Number."
exit 1
fi
fi

echo "Collecting information about PR #$PR_NUMBER of $GITHUB_REPOSITORY..."

if [[ -z "$GITHUB_TOKEN" ]]; then
Expand Down

0 comments on commit 3bae84f

Please sign in to comment.