Skip to content

Commit

Permalink
Add Action Manifest
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Gasch <[email protected]>
  • Loading branch information
Michael Gasch committed May 3, 2021
1 parent 86f5c81 commit d10268b
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 0 deletions.
57 changes: 57 additions & 0 deletions README.md
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.
35 changes: 35 additions & 0 deletions action.yml
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

0 comments on commit d10268b

Please sign in to comment.