Skip to content

Commit 040232b

Browse files
committed
src/getProperties.js: add prefix support
1 parent bdbb575 commit 040232b

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

action.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = async ({ github, context, inputs, actionPath }) => {
1212
if (debug) console.log('Initializing puLL-Merge')
1313

1414
const config = await getConfig({ owner: context.repo.owner, repo: context.repo.repo, path: '.github/pull-merge.json', debug, github })
15-
const properties = await getProperties({ owner: context.repo.owner, repo: context.repo.repo, debug, github })
15+
const properties = await getProperties({ owner: context.repo.owner, repo: context.repo.repo, debug, github, prefix: 'pull_merge_' })
1616

1717
const options = Object.assign({
1818
debounce_time: '6',

src/getProperties.js

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default async function getProperties ({ owner, repo, github, githubToken, debug = false }) {
1+
export default async function getProperties ({ owner, repo, github, githubToken, debug = false, prefix = '' }) {
22
if (!github && githubToken) {
33
const { Octokit } = await import('@octokit/core')
44

@@ -14,10 +14,27 @@ export default async function getProperties ({ owner, repo, github, githubToken,
1414
}
1515
})
1616
if (debug) console.log(properties)
17-
return properties.data.reduce((acc, cur) => {
18-
acc[cur.property_name] = cur.value
19-
return acc
20-
}, {})
17+
18+
const output = {}
19+
20+
// copy properties not starting with prefix to output
21+
properties.data.forEach(c => {
22+
if (!c.property_name.startsWith(prefix)) {
23+
output[c.property_name] = c.value
24+
}
25+
})
26+
27+
// copy properties starting with prefix to output
28+
if (prefix) {
29+
properties.data.forEach(c => {
30+
if (c.property_name.startsWith(prefix)) {
31+
const name = c.property_name.substring(prefix.length)
32+
output[name] = c.value
33+
}
34+
})
35+
}
36+
37+
return output
2138
} catch (err) {
2239
console.log(err)
2340
return {}

0 commit comments

Comments
 (0)