Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwoodworth committed Feb 4, 2024
1 parent a2e9321 commit 71c661d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
52 changes: 51 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,52 @@
# require-pr-action
Use this action to revert commits on a branch that were pushed without a PR. Can limit to only certain users

> [!WARNING]
> Using this action can result in destroying hard work. Please be careful when using this action
Are you unable to use branch protection because you're working on a private repository? Is there someone on your team who keeps pushing commits without PRs despite being asked not to? This action is for you! Simply use this action in your repo, and any commits pushed by certain users (or all) will automatically be hard reset if they did not submit a PR.

## Usage

This action has one input: `users`. Specify the list of github usernames separated by commas, and this action will apply to all of those users when committing. If this prop is not specified, this action will apply to *all* users.

Trigger this action on push events on the branches you want to require PRs for, and be sure to give permissions to read PRs and write to the repository.

## Examples

```yaml
name: "Enforce PR Requirement on main for all users"

on:
push:
branches:
- "main"

jobs:
revert:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- uses: peterwoodworth/require-pr-action@v1
```
```yaml
name: "Enforce PR Requirement on main for Peter and Sean"

on:
push:
branches:
- "main"

jobs:
revert:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- uses: peterwoodworth/require-pr-action@v1
with:
users: peter,sean
```
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ runs:
with:
script: |
const users = '${{ inputs.users }}'.split(',');
console.log(users.length);
if (!users.includes(context.actor) && users[0]) {
return true;
}
Expand Down

0 comments on commit 71c661d

Please sign in to comment.