Skip to content

Commit e7fd75b

Browse files
authored
Merge pull request #54 from ReenigneArcher/feat/add-url-only-input-option
feat: add url only input option
2 parents 668f251 + dcf7587 commit e7fd75b

File tree

6 files changed

+75
-9
lines changed

6 files changed

+75
-9
lines changed

.vscode/launch.json

+21
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@
2323
"NODE_ENV": "development"
2424
},
2525
"console": "integratedTerminal"
26+
},
27+
{
28+
"name": "Dry-Run",
29+
"type": "node",
30+
"request": "launch",
31+
"runtimeArgs": [
32+
"--inspect-brk",
33+
],
34+
"args": [
35+
"${workspaceRoot}/index.js",
36+
],
37+
"stopOnEntry": false,
38+
"cwd": "${workspaceFolder}",
39+
"env": {
40+
"NODE_ENV": "development",
41+
"INPUT_DRY-RUN": "true",
42+
"INPUT_FEED": "https://lizardbyte.github.io/feed.xml",
43+
"INPUT_MAX-AGE": "120h",
44+
"INPUT_GITHUB-TOKEN": "",
45+
},
46+
"console": "integratedTerminal"
2647
}
2748
]
2849
}

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ Only create an issue if the content matches the specified [regular expression](h
5656

5757
To _exclude_ items based on their content, you can use a negative lookahead. For example, to filter out all feed items whose text contains "TEST", use a regular expression like `/^(?!.*TEST)/`.
5858

59+
### `url-only`
60+
61+
If set, only the URL is added to the issue body
62+
5963
## Outputs
6064

6165
### `issues`
@@ -96,6 +100,7 @@ jobs:
96100
dry-run: false
97101
max-age: 48h
98102
labels: git
103+
url-only: false
99104
```
100105
101106
### Real Usage

action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: "Limit to feed items whose titles match this regular expression"
2929
content-pattern:
3030
description: "Limit to feed items whose contents match this regular expression"
31+
url-only:
32+
description: "If set, only the URL is added to the issue body"
33+
default: 'false'
34+
required: false
3135
outputs:
3236
issues:
3337
description: "issue IDs, comma separated"

dist/index.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ const parseDurationInMilliseconds = (text) => {
2828

2929
const run = async () => {
3030
try {
31-
let issueTitlePrefix = core.getInput('prefix')
32-
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
31+
// boolean inputs
3332
let dryRun = core.getInput('dry-run')
3433
if (dryRun) dryRun = dryRun === 'true'
3534
let aggregate = core.getInput('aggregate')
3635
if (aggregate) aggregate = aggregate === 'true'
36+
let urlOnly = core.getInput('url-only')
37+
if (urlOnly) urlOnly = urlOnly === 'true'
38+
39+
// integer inputs
3740
let characterLimit = core.getInput('character-limit')
3841
if (characterLimit) characterLimit = parseInt(characterLimit)
42+
43+
// string inputs
44+
let issueTitlePrefix = core.getInput('prefix')
45+
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
3946
const titlePattern = core.getInput('title-pattern')
4047
const contentPattern = core.getInput('content-pattern')
4148

@@ -49,7 +56,18 @@ const run = async () => {
4956
const octokit = getOctokit(core.getInput('github-token'))
5057

5158
// Instantiate feed parser
52-
const feed = await (new RSSParser({ xml2js: { trim: true } })).parseURL(core.getInput('feed'))
59+
const rssParserOptions = {
60+
headers: {
61+
'User-Agent': 'rss-parser',
62+
Accept: 'application/rss+xml',
63+
// do not keep the connection alive
64+
Connection: 'close'
65+
},
66+
xml2js: {
67+
trim: true
68+
}
69+
}
70+
const feed = await (new RSSParser(rssParserOptions)).parseURL(core.getInput('feed'))
5371
core.info(feed && feed.title)
5472
if (!feed.items || feed.items.length === 0) return
5573

@@ -103,7 +121,7 @@ const run = async () => {
103121
}
104122

105123
// Render issue content
106-
const body = `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`
124+
const body = urlOnly ? item.link : `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`
107125

108126
// Default to creating an issue per item
109127
// Create first issue if aggregate

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,21 @@ const parseDurationInMilliseconds = (text) => {
2222

2323
const run = async () => {
2424
try {
25-
let issueTitlePrefix = core.getInput('prefix')
26-
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
25+
// boolean inputs
2726
let dryRun = core.getInput('dry-run')
2827
if (dryRun) dryRun = dryRun === 'true'
2928
let aggregate = core.getInput('aggregate')
3029
if (aggregate) aggregate = aggregate === 'true'
30+
let urlOnly = core.getInput('url-only')
31+
if (urlOnly) urlOnly = urlOnly === 'true'
32+
33+
// integer inputs
3134
let characterLimit = core.getInput('character-limit')
3235
if (characterLimit) characterLimit = parseInt(characterLimit)
36+
37+
// string inputs
38+
let issueTitlePrefix = core.getInput('prefix')
39+
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
3340
const titlePattern = core.getInput('title-pattern')
3441
const contentPattern = core.getInput('content-pattern')
3542

@@ -43,7 +50,18 @@ const run = async () => {
4350
const octokit = getOctokit(core.getInput('github-token'))
4451

4552
// Instantiate feed parser
46-
const feed = await (new RSSParser({ xml2js: { trim: true } })).parseURL(core.getInput('feed'))
53+
const rssParserOptions = {
54+
headers: {
55+
'User-Agent': 'rss-parser',
56+
Accept: 'application/rss+xml',
57+
// do not keep the connection alive
58+
Connection: 'close'
59+
},
60+
xml2js: {
61+
trim: true
62+
}
63+
}
64+
const feed = await (new RSSParser(rssParserOptions)).parseURL(core.getInput('feed'))
4765
core.info(feed && feed.title)
4866
if (!feed.items || feed.items.length === 0) return
4967

@@ -97,7 +115,7 @@ const run = async () => {
97115
}
98116

99117
// Render issue content
100-
const body = `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`
118+
const body = urlOnly ? item.link : `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`
101119

102120
// Default to creating an issue per item
103121
// Create first issue if aggregate

0 commit comments

Comments
 (0)