Skip to content

Commit

Permalink
Merge pull request #6 from tzkhan/v1.1
Browse files Browse the repository at this point in the history
Add ability to replace title and body
  • Loading branch information
tzkhan authored Apr 26, 2020
2 parents 4b206c4 + b39c8bb commit a5bc56e
Show file tree
Hide file tree
Showing 8 changed files with 11,370 additions and 4,094 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ jobs:
pr_update_text:
runs-on: ubuntu-latest
steps:
- uses: tzkhan/pr-update-action@v1
- uses: tzkhan/pr-update-action
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
branch-regex: 'FOO-\d+'
branch-regex: 'foo-\d+'
lowercase-branch: false
title-template: '[%branch%]'
replace-title: false
title-prefix-space: true
uppercase-title: false
body-template: '[Link to %branch%](https://url/to/browse/ticket/%branch%)'
replace-body: false
body-prefix-newline-count: 2
uppercase-body: false
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ typings/

# next.js build output
.next

# Custom
[Ll]ocal/
*.local.*
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pull Request Updater

This is a GitHub Action that updates a pull request with information extracted from branch name.
This is a GitHub Action that updates a pull request with information extracted from branch name. The pull request title and body can either be prefixed or replaced.

## Usage

Expand All @@ -20,14 +20,16 @@ jobs:
- uses: tzkhan/pr-update-action@v1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}" # required - allows the action to make calls to GitHub's rest API
branch-regex: 'FOO-\d+' # required - regex to match text from the head branch name
branch-regex: 'foo-\d+' # required - regex to match text from the head branch name
lowercase-branch: true # optional - whether to lowercase branch name before matching
title-template: '[%branch%]' # optional - text template to prefix title
title-template: '[%branch%]' # required - text template to update title with
replace-title: false # optional - whether to prefix or replace title with title-template
title-prefix-space: true # optional - whether to add a space after title prefix
uppercase-title: true # optional - whether to uppercase title prefix
body-template: '[%branch%](https://browse/ticket/%branch%)' # optional - text template to prefix body
uppercase-title: true # optional - whether to uppercase matched branch info in title
body-template: '[%branch%](https://browse/ticket/%branch%)' # required - text template to prefix body
replace-body: false # optional - whether to prefix or replace body with body-template
body-prefix-newline-count: 2 # optional - number of newlines to insert after body prefix
uppercase-body: true # optional - whether to uppercase body prefix
uppercase-body: true # optional - whether to uppercase matched branch info in body
```

`body-template` can be set to a GitHub secret if necessary to avoid leaking sensitive data in the URLs for instance. `body-template: ${{ secrets.PR_BODY_PREFIX_TEMPLATE }}`
Expand All @@ -52,9 +54,11 @@ jobs:
branch-regex: 'foo-\d+'
lowercase-branch: false
title-template: '[%branch%]'
replace-title: false
title-prefix-space: true
uppercase-title: true
body-template: '[Link to %branch%](https://url/to/browse/ticket/%branch%)'
replace-body: false
body-prefix-newline-count: 2
uppercase-body: true
```
Expand Down
22 changes: 15 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,49 @@ description: 'GitHub Action that updates a pull request with information extract
author: 'Tamim Khan'
runs:
using: 'node12'
main: 'index.js'
main: 'dist/index.js'
inputs:
repo-token:
description: 'The GITHUB_TOKEN secret'
required: true
branch-regex:
description: 'Regex to match branch name'
required: true
default: 'FOO-\d+'
default: 'foo-\d+'
lowercase-branch:
description: 'Should lowercase branch name before matching text'
required: false
default: true
default: false
title-template:
description: 'Title prefix template where branch info gets substituted in'
description: 'Title template where branch info gets substituted in'
required: true
default: '[%branch%]'
replace-title:
description: 'Should replace title instead of prefixing'
required: false
default: false
title-prefix-space:
description: 'Should add space after title prefix'
required: false
default: true
uppercase-title:
description: 'Should uppercase title prefix'
description: 'Should uppercase matched branch info in title'
required: false
default: true
body-template:
description: 'Body prefix template where branch info gets substituted in'
description: 'Body template where branch info gets substituted in'
required: true
default: '[%branch%](https://url/to/browse/ticket/%branch%)'
replace-body:
description: 'Should replace body instead of prefixing'
required: false
default: false
body-prefix-newline-count:
description: 'Number of newlines to separate body and its prefix'
required: false
default: 2
uppercase-body:
description: 'Should uppercase body prefix'
description: 'Should uppercase matched branch info in body'
required: false
default: true
branding:
Expand Down
Loading

0 comments on commit a5bc56e

Please sign in to comment.