-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
36 lines (29 loc) · 978 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 exec = require('@actions/exec')
async function run() {
try {
const serviceAccountKey = core.getInput("SERVICE_ACCOUNT_KEY", {required: true})
const host = core.getInput('HOST', {required: true})
let myOutput = '';
let myError = '';
const options = {
silent: true
}
options.listeners = {
stdout: (data) => {
myOutput += data.toString();
},
stderr: (data) => {
myError += data.toString();
}
};
const registry = 'https://' + host
console.log(`Logging into ${registry}`)
await exec.exec('docker', ['login', '-u', '_json_key', '-p', serviceAccountKey, registry], options)
.then(() => {console.log(myOutput)})
.catch(() => {throw {message: myError}})
} catch (error) {
core.setFailed(error.message)
}
}
run()