Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
"NODE_ENV": "development"
},
"console": "integratedTerminal"
},
{
"name": "Dry-Run",
"type": "node",
"request": "launch",
"runtimeArgs": [
"--inspect-brk",
],
"args": [
"${workspaceRoot}/index.js",
],
"stopOnEntry": false,
"cwd": "${workspaceFolder}",
"env": {
"NODE_ENV": "development",
"INPUT_DRY-RUN": "true",
"INPUT_FEED": "https://lizardbyte.github.io/feed.xml",
"INPUT_MAX-AGE": "120h",
"INPUT_GITHUB-TOKEN": "",
},
"console": "integratedTerminal"
}
]
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ Only create an issue if the content matches the specified [regular expression](h

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)/`.

### `url-only`

If set, only the URL is added to the issue body

## Outputs

### `issues`
Expand Down Expand Up @@ -96,6 +100,7 @@ jobs:
dry-run: false
max-age: 48h
labels: git
url-only: false
```

### Real Usage
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: "Limit to feed items whose titles match this regular expression"
content-pattern:
description: "Limit to feed items whose contents match this regular expression"
url-only:
description: "If set, only the URL is added to the issue body"
default: 'false'
required: false
outputs:
issues:
description: "issue IDs, comma separated"
Expand Down
26 changes: 22 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ const parseDurationInMilliseconds = (text) => {

const run = async () => {
try {
let issueTitlePrefix = core.getInput('prefix')
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
// boolean inputs
let dryRun = core.getInput('dry-run')
if (dryRun) dryRun = dryRun === 'true'
let aggregate = core.getInput('aggregate')
if (aggregate) aggregate = aggregate === 'true'
let urlOnly = core.getInput('url-only')
if (urlOnly) urlOnly = urlOnly === 'true'

// integer inputs
let characterLimit = core.getInput('character-limit')
if (characterLimit) characterLimit = parseInt(characterLimit)

// string inputs
let issueTitlePrefix = core.getInput('prefix')
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
const titlePattern = core.getInput('title-pattern')
const contentPattern = core.getInput('content-pattern')

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

// Instantiate feed parser
const feed = await (new RSSParser({ xml2js: { trim: true } })).parseURL(core.getInput('feed'))
const rssParserOptions = {
headers: {
'User-Agent': 'rss-parser',
Accept: 'application/rss+xml',
// do not keep the connection alive
Connection: 'close'
},
xml2js: {
trim: true
}
}
const feed = await (new RSSParser(rssParserOptions)).parseURL(core.getInput('feed'))
core.info(feed && feed.title)
if (!feed.items || feed.items.length === 0) return

Expand Down Expand Up @@ -103,7 +121,7 @@ const run = async () => {
}

// Render issue content
const body = `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`
const body = urlOnly ? item.link : `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`

// Default to creating an issue per item
// Create first issue if aggregate
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@ const parseDurationInMilliseconds = (text) => {

const run = async () => {
try {
let issueTitlePrefix = core.getInput('prefix')
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
// boolean inputs
let dryRun = core.getInput('dry-run')
if (dryRun) dryRun = dryRun === 'true'
let aggregate = core.getInput('aggregate')
if (aggregate) aggregate = aggregate === 'true'
let urlOnly = core.getInput('url-only')
if (urlOnly) urlOnly = urlOnly === 'true'

// integer inputs
let characterLimit = core.getInput('character-limit')
if (characterLimit) characterLimit = parseInt(characterLimit)

// string inputs
let issueTitlePrefix = core.getInput('prefix')
issueTitlePrefix = issueTitlePrefix ? issueTitlePrefix + ' ' : ''
const titlePattern = core.getInput('title-pattern')
const contentPattern = core.getInput('content-pattern')

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

// Instantiate feed parser
const feed = await (new RSSParser({ xml2js: { trim: true } })).parseURL(core.getInput('feed'))
const rssParserOptions = {
headers: {
'User-Agent': 'rss-parser',
Accept: 'application/rss+xml',
// do not keep the connection alive
Connection: 'close'
},
xml2js: {
trim: true
}
}
const feed = await (new RSSParser(rssParserOptions)).parseURL(core.getInput('feed'))
core.info(feed && feed.title)
if (!feed.items || feed.items.length === 0) return

Expand Down Expand Up @@ -97,7 +115,7 @@ const run = async () => {
}

// Render issue content
const body = `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`
const body = urlOnly ? item.link : `${markdown || ''}\n${item.link ? `\n${item.link}` : ''}`

// Default to creating an issue per item
// Create first issue if aggregate
Expand Down
Loading