forked from juliangruber/read-file-action
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
40 lines (34 loc) · 953 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict'
const core = require('@actions/core')
const { promises: fs } = require('fs')
const main = async () => {
const path = core.getInput('path')
const content = await fs.readFile(path, 'utf8')
const regexList = [
/(?<=\*\*Team Name:\*\* ).*/g,
/(?<=\*\*Project Name:\*\* ).*/g,
/(?<=\*\*Contact Name:\*\* ).*/g,
/(?<=\*\*Contact Email:\*\* ).*/g,
/(?<=\*\*Total Costs:\*\* ).*(?= BTC)/gi,
/(?<=\*\*Total Costs:\*\* ).*(?=( DAI)|( USD))/gi,
/(?<=\*\*Registered Address:\*\* ).*/g
]
const outputs = [
'team_name',
'project_name',
'contact_name',
'contact_email',
'total_cost_btc',
'total_cost_dai',
'address'
]
regexList.map(function (reg, i) {
try {
const result = content.match(reg)[0]
core.setOutput(outputs[i], result)
} catch {
core.warning(`Match not found for: ${outputs[i]}`)
}
})
}
main().catch(err => core.setFailed(err.message))