-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfast-envsubst.ts
37 lines (30 loc) · 879 Bytes
/
fast-envsubst.ts
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
import * as core from '@actions/core'
import * as path from 'path'
import * as dotenv from 'dotenv'
import envsub from 'envsub'
const run = async (): Promise<void> => {
try {
const inFile = core.getInput('in-file')
const outFile = core.getInput('out-file')
const envFile = core.getInput('env-file')
core.debug(`in file: ${inFile}`)
core.debug(`out file: ${outFile}`)
core.debug(`env file: ${envFile}`)
if (envFile) {
dotenv.config({path: path.resolve(process.cwd(), envFile)})
}
await envsub({
outputFile: outFile,
templateFile: inFile,
})
core.setOutput('out-file-created', 'true')
} catch (error) {
core.setOutput('out-file-created', 'false')
core.setFailed(error.message)
}
}
// Don't auto-execute in the test environment
if (process.env['NODE_ENV'] !== 'test') {
run()
}
export default run