Skip to content

Commit a5bc56e

Browse files
authored
Merge pull request #6 from tzkhan/v1.1
Add ability to replace title and body
2 parents 4b206c4 + b39c8bb commit a5bc56e

File tree

8 files changed

+11370
-4094
lines changed

8 files changed

+11370
-4094
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ jobs:
66
pr_update_text:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: tzkhan/pr-update-action@v1
9+
- uses: tzkhan/pr-update-action
1010
with:
1111
repo-token: "${{ secrets.GITHUB_TOKEN }}"
12-
branch-regex: 'FOO-\d+'
12+
branch-regex: 'foo-\d+'
1313
lowercase-branch: false
1414
title-template: '[%branch%]'
15+
replace-title: false
1516
title-prefix-space: true
1617
uppercase-title: false
1718
body-template: '[Link to %branch%](https://url/to/browse/ticket/%branch%)'
19+
replace-body: false
1820
body-prefix-newline-count: 2
1921
uppercase-body: false

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ typings/
6464

6565
# next.js build output
6666
.next
67+
68+
# Custom
69+
[Ll]ocal/
70+
*.local.*

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Pull Request Updater
22

3-
This is a GitHub Action that updates a pull request with information extracted from branch name.
3+
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.
44

55
## Usage
66

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

3335
`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 }}`
@@ -52,9 +54,11 @@ jobs:
5254
branch-regex: 'foo-\d+'
5355
lowercase-branch: false
5456
title-template: '[%branch%]'
57+
replace-title: false
5558
title-prefix-space: true
5659
uppercase-title: true
5760
body-template: '[Link to %branch%](https://url/to/browse/ticket/%branch%)'
61+
replace-body: false
5862
body-prefix-newline-count: 2
5963
uppercase-body: true
6064
```

action.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,49 @@ description: 'GitHub Action that updates a pull request with information extract
33
author: 'Tamim Khan'
44
runs:
55
using: 'node12'
6-
main: 'index.js'
6+
main: 'dist/index.js'
77
inputs:
88
repo-token:
99
description: 'The GITHUB_TOKEN secret'
1010
required: true
1111
branch-regex:
1212
description: 'Regex to match branch name'
1313
required: true
14-
default: 'FOO-\d+'
14+
default: 'foo-\d+'
1515
lowercase-branch:
1616
description: 'Should lowercase branch name before matching text'
1717
required: false
18-
default: true
18+
default: false
1919
title-template:
20-
description: 'Title prefix template where branch info gets substituted in'
20+
description: 'Title template where branch info gets substituted in'
2121
required: true
2222
default: '[%branch%]'
23+
replace-title:
24+
description: 'Should replace title instead of prefixing'
25+
required: false
26+
default: false
2327
title-prefix-space:
2428
description: 'Should add space after title prefix'
2529
required: false
2630
default: true
2731
uppercase-title:
28-
description: 'Should uppercase title prefix'
32+
description: 'Should uppercase matched branch info in title'
2933
required: false
3034
default: true
3135
body-template:
32-
description: 'Body prefix template where branch info gets substituted in'
36+
description: 'Body template where branch info gets substituted in'
3337
required: true
3438
default: '[%branch%](https://url/to/browse/ticket/%branch%)'
39+
replace-body:
40+
description: 'Should replace body instead of prefixing'
41+
required: false
42+
default: false
3543
body-prefix-newline-count:
3644
description: 'Number of newlines to separate body and its prefix'
3745
required: false
3846
default: 2
3947
uppercase-body:
40-
description: 'Should uppercase body prefix'
48+
description: 'Should uppercase matched branch info in body'
4149
required: false
4250
default: true
4351
branding:

0 commit comments

Comments
 (0)