Skip to content

Commit e15315c

Browse files
authored
feat: add option to include/exclude body as regex target (#70)
* feat: add option to include/exclude body as regex target * build: create build
1 parent c43637b commit e15315c

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ on:
3939
permissions:
4040
issues: write
4141
contents: read
42-
42+
4343
jobs:
4444
triage:
4545
runs-on: ubuntu-latest
@@ -79,7 +79,7 @@ on:
7979
permissions:
8080
issues: write
8181
contents: read
82-
82+
8383
jobs:
8484
triage:
8585
runs-on: ubuntu-latest
@@ -125,7 +125,7 @@ on:
125125
permissions:
126126
issues: write
127127
contents: read
128-
128+
129129
jobs:
130130
triage:
131131
runs-on: ubuntu-latest
@@ -138,6 +138,31 @@ jobs:
138138
repo-token: ${{ github.token }}
139139
```
140140

141+
### Example of *only* including the issue title, but not the body in the regex target
142+
143+
Set `include-title: 1` and `include-body: 0`.
144+
145+
```yml
146+
name: "Issue Labeler"
147+
on:
148+
issues:
149+
types: [opened, edited]
150+
151+
permissions:
152+
issues: write
153+
contents: read
154+
155+
jobs:
156+
triage:
157+
runs-on: ubuntu-latest
158+
steps:
159+
- uses: github/[email protected] #May not be the latest version
160+
with:
161+
configuration-path: .github/labeler.yml
162+
include-title: 1
163+
include-body: 0
164+
```
165+
141166
### Syncing Labels
142167

143168
By default, labels that no longer match are not removed from the issue. To enable this functionality, explicity

action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ inputs:
2222
description: 'The name of the label that should be added to an issue where the specified `version-regex` can not be found.'
2323
required: false
2424
include-title:
25-
description: 'Include the title in addition to the body in the regex target'
25+
description: 'Include the title in the regex target'
2626
required: false
2727
default: "0"
28+
include-body:
29+
description: 'Include the body in the regex target'
30+
required: false
31+
default: "1"
2832
sync-labels:
2933
description: 'Remove the label from the issue if the label regex does not match'
3034
required: false
@@ -33,6 +37,7 @@ inputs:
3337
description: 'The number of the issue/PR to label'
3438
required: false
3539
default: ${{ github.event.issue.number || github.event.pull_request.number }}
40+
3641
outputs:
3742
labels-added:
3843
description: 'The labels that were added by the action, as a stringified array.'

lib/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ async function run() {
2020
required: false,
2121
});
2222
const includeTitle = parseInt(getInput("include-title", { required: false }));
23+
const includeBody = parseInt(getInput("include-body", { required: false }));
2324
const syncLabels = parseInt(getInput("sync-labels", { required: false }));
2425

2526
const issue_number = parseInt(getInput("issue-number", { required: true }))
@@ -92,7 +93,7 @@ async function run() {
9293

9394
let issueContent = "";
9495
if (includeTitle === 1) issueContent += `${issue_title}\n\n`;
95-
issueContent += issue_body;
96+
if (includeBody === 1) issueContent += issue_body;
9697

9798
for (const [label, globs] of labelRegexes.entries()) {
9899
if (checkRegexes(issueContent, globs)) {

0 commit comments

Comments
 (0)