Skip to content
This repository was archived by the owner on May 7, 2024. It is now read-only.

Commit 9d21e09

Browse files
authored
Allow PR_NUMBER to be set externally (#76)
1 parent 1eb6e5e commit 9d21e09

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ Example
5050
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
5151
```
5252

53+
You can also optionally specify the PR number of the branch to rebase,
54+
if the action you're running doesn't directly refer to a specific
55+
pull request:
56+
57+
```yaml
58+
- name: Automatic Rebase
59+
uses: cirrus-actions/[email protected]
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
62+
PR_NUMBER: 1245
63+
```
5364

5465

5566
## Restricting who can call the action

entrypoint.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22

33
set -e
44

5-
PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH")
6-
if [[ "$PR_NUMBER" == "null" ]]; then
7-
PR_NUMBER=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
8-
fi
9-
if [[ "$PR_NUMBER" == "null" ]]; then
10-
echo "Failed to determine PR Number."
11-
exit 1
5+
if [ -z "$PR_NUMBER" ]; then
6+
PR_NUMBER=$(jq -r ".pull_request.number" "$GITHUB_EVENT_PATH")
7+
if [[ "$PR_NUMBER" == "null" ]]; then
8+
PR_NUMBER=$(jq -r ".issue.number" "$GITHUB_EVENT_PATH")
9+
fi
10+
if [[ "$PR_NUMBER" == "null" ]]; then
11+
echo "Failed to determine PR Number."
12+
exit 1
13+
fi
1214
fi
15+
1316
echo "Collecting information about PR #$PR_NUMBER of $GITHUB_REPOSITORY..."
1417

1518
if [[ -z "$GITHUB_TOKEN" ]]; then

0 commit comments

Comments
 (0)