Skip to content

Commit

Permalink
CH-13129 - enable exemptions by username(s) (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Paquette authored Jun 19, 2020
1 parent 397a732 commit 32f7b26
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## 1.2.0 (June 17, 2020)

Provide a configuration option to exempt users from the action rules. Most useful for automated and bot PRs.

## 1.1.0 (May 17, 2020)

Added detection of ticket checking to include branches

## 1.0.0 (April 8, 2020)

Initial release! :tada:
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- name: Check for ticket
uses: neofinancial/ticket-check-action@v1.1.0
uses: neofinancial/ticket-check-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ticketPrefix: '#'
Expand All @@ -67,7 +67,7 @@ jobs:

steps:
- name: Check for ticket
uses: neofinancial/ticket-check-action@v1.1.0
uses: neofinancial/ticket-check-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ticketPrefix: 'PROJ-'
Expand All @@ -93,7 +93,7 @@ jobs:

steps:
- name: Check for ticket
uses: neofinancial/ticket-check-action@v1.1.0
uses: neofinancial/ticket-check-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ticketPrefix: 'CH-'
Expand All @@ -120,6 +120,7 @@ jobs:
| bodyRegexFlags | | The flags applied to the body regular expression when searching for a shorthand reference | gim |
| bodyURLRegex | | The regular expression used to search the body for a URL reference (example `https://github.com/octocat/hello-world/issues/1`) | |
| bodyURLRegexFlags | | The flags applied to the body regular expression when searching for a URL reference | gim |
| exemptUsers | | Comma seperated string of usernames that will be exempt from all checks. Most useful for bot/automated PRs (example "octocat,dependabot") | |

## Caveat

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ inputs:
default: 'gim'
required: true

exemptUsers:
description: 'User(s) who will be exempt from the ticket check rules. Particularly useful for automated/bot PRs'
default: ''
required: false

token:
description: 'GitHub authentication token'
required: true
Expand Down
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ticket-check-action",
"description": "Verify that your pull request titles start with a ticket ID",
"version": "1.1.0",
"version": "1.2.0",
"author": "Neo Financial Engineering <[email protected]>",
"license": "MIT",
"repository": {
Expand Down
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ async function run(): Promise<void> {
const token = getInput('token', { required: true });
const client = new GitHub(token);
const pullRequest = context.issue;
const { sender } = context.payload;

// Exempt Users
const exemptUsers = getInput('exemptUsers', { required: true })
.split(',')
.map(user => user.trim());

if (sender && exemptUsers.includes(sender.login)) {
debug('User is listed as exempt');
debug(`Exempt Users: ${exemptUsers.join(', ')}`);
debug(`Pull Request Owner: ${sender.login}`);
return;
}

// get the title format and ticket prefix
const ticketPrefix = getInput('ticketPrefix', { required: true });
Expand Down

0 comments on commit 32f7b26

Please sign in to comment.