-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Michael Gasch <[email protected]>
- Loading branch information
Michael Gasch
committed
May 3, 2021
1 parent
86f5c81
commit d10268b
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# About | ||
|
||
Github Action to check the specified string, e.g. Github PR title, for | ||
work-in-progress ("WIP") patterns using regular expressions in `BASH`. | ||
|
||
# Usage | ||
|
||
## Simple with Defaults | ||
|
||
```yaml | ||
name: Check "WIP" in PR Title | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check WIP in PR Title | ||
uses: embano1/wip@v1 | ||
``` | ||
## Custom Options | ||
```yaml | ||
name: Check "WIP" in PR Title | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check WIP in PR Title | ||
uses: embano1/wip@v1 | ||
with: | ||
# this is also the default value | ||
title: "${{ github.event.pull_request.title }}" | ||
|
||
# only matches PRs where title is "WIP" only | ||
regex: "^WIP$" | ||
|
||
``` | ||
|
||
## Configuration Options | ||
|
||
| Input | Type | Required | Default | Description | | ||
|---------|----------|----------|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `title` | `string` | yes | `${{ github.event.pull_request.title }}` | The title to perform regular expression pattern matching against. Typically a field from the Github [`context`](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#github-context) is used. | | ||
| `regex` | `string` | yes | `^[[:space:]]*(WIP)+(:)*` | The regular expression to perform. The default value matches the word `WIP` (optionally followed by `:`) and ignores any whitespace character(s) at the beginning of the text | | ||
|
||
⚠️ Currently regular expression pattern matching is **case-insensitive**, i.e. | ||
`wip` would also match. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "Check WIP" | ||
description: "Checks for WIP patterns in Titles" | ||
branding: | ||
icon: box | ||
color: blue | ||
inputs: | ||
title: | ||
description: "Text to perform pattern match against" | ||
required: true | ||
default: "${{ github.event.pull_request.title }}" | ||
regex: | ||
description: "Regex pattern to match in title" | ||
required: true | ||
# starts with zero or more leading whitespace chars, WIP and zero or more colons | ||
default: "^[[:space:]]*(WIP)+(:)*" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- shell: bash | ||
run: | | ||
set -ex | ||
# TODO (@mgasch): make configurable | ||
# case-insensitive | ||
shopt -s nocasematch | ||
if [[ "${{ inputs.title }}" =~ ${{ inputs.regex }} ]]; then | ||
echo "::error::Title marked as work in progress" | ||
exit 1 | ||
else | ||
echo "::debug::Title not marked as work in progress" | ||
fi | ||
# unset nocasematch option | ||
shopt -u nocasematch |