-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (29 loc) · 1.04 KB
/
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
const core = require("@actions/core")
const path = require("path")
const fs = require("fs")
try {
console.log("Adding secrets...")
const taskDefinition = core.getInput("task-definition")
const secrets = core.getInput("secrets")
const taskDefinitionPath = path.isAbsolute(taskDefinition)
? taskDefinition
: path.join(process.env.GITHUB_WORKSPACE, taskDefinition)
if (!fs.existsSync(taskDefinitionPath)) {
throw new Error(`Task definition file does not exist: ${taskDefinition}`)
}
const secretsPath = path.isAbsolute(secrets)
? secrets
: path.join(process.env.GITHUB_WORKSPACE, secrets)
if (!fs.existsSync(secretsPath)) {
throw new Error(`Secrets file does not exist: ${secrets}`)
}
const taskDefinitionContents = require(taskDefinitionPath)
const secretsContents = require(secretsPath)
taskDefinitionContents.containerDefinitions[0].secrets = secretsContents
fs.writeFileSync(
taskDefinitionPath,
JSON.stringify(taskDefinitionContents, null, 4)
)
} catch (error) {
core.setFailed(error.message)
}