-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
36 lines (30 loc) · 882 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
const core = require('@actions/core')
const { execSync } = require('child_process')
// Support Functions
const createCatFile = ({ email, api_key }) => `cat >~/.netrc <<EOF
machine api.heroku.com
login ${email}
password ${api_key}
machine git.heroku.com
login ${email}
password ${api_key}
EOF`
// Input Variables
let heroku = {}
heroku.api_key = core.getInput('heroku_api_key')
heroku.email = core.getInput('heroku_email')
heroku.app_name = core.getInput('heroku_app_name')
// Program logic
try {
execSync(createCatFile(heroku))
console.log('Created and wrote to ~./netrc')
execSync('heroku login')
console.log('Successfully logged into heroku')
execSync(`heroku pipelines:promote -a ${heroku.app_name}`)
core.setOutput(
'status',
'Successfully promoted heroku app ' + heroku.app_name,
)
} catch (err) {
core.setFailed(err.toString())
}