Skip to content

Commit

Permalink
feat: support pull_request_target events
Browse files Browse the repository at this point in the history
`pull_request` events don't have the necessary privileges to access
private repos. Adding support for the `pull_request_target` event will
allow private repos to also use commit lint.
  • Loading branch information
kadams54 committed Jul 1, 2024
1 parent b98c73f commit 6876557
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
uses: opensource-nepal/commitlint@v1
```

> **_NOTE:_** commitlint GitHub Actions will only be triggered by "push" or "pull_request" events.
> **_NOTE:_** commitlint GitHub Actions will only be triggered by "push", "pull_request", or "pull_request_target" events. The difference between "pull_request" and "pull_request_target" is that "pull_request" is more secure for public repos while "pull_request_target" is necessary for private repos.

#### GitHub Action Inputs

Expand Down
3 changes: 3 additions & 0 deletions github_actions/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# Events
EVENT_PUSH = "push"
EVENT_PULL_REQUEST = "pull_request"
EVENT_PULL_REQUEST_TARGET = "pull_request_target"

# Inputs
INPUT_FAIL_ON_ERROR = "INPUT_FAIL_ON_ERROR"
Expand Down Expand Up @@ -176,6 +177,8 @@ def main() -> None:
_handle_push_event(event)
elif event.event_name == EVENT_PULL_REQUEST:
_handle_pr_event(event)
elif event.event_name == EVENT_PULL_REQUEST_TARGET:
_handle_pr_event(event)
elif event.event_name is None:
sys.stdout.write("No any events, skipping\n")
else:
Expand Down

0 comments on commit 6876557

Please sign in to comment.