-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (24 loc) · 969 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
const core = require('@actions/core');
const github = require('@actions/github');
let options = {
apiVersion: 'v1',
endpoint: core.getInput('address'),
};
const vault = require("node-vault")(options);
token = vault.approleLogin({
role_id: core.getInput('role_id'),
secret_id: core.getInput('secret_id')
}).then((auth) => {
let token = auth['auth']['client_token'];
vault.token = token;
vault.read(core.getInput('path'))
.then((result) => {
let secrets = result['data'];
let env = '';
Object.keys(secrets).forEach(function(key){
env += key + '=' + secrets[key] + "\n";
});
core.setOutput('secrets_json', JSON.stringify(secretsObject));
core.setOutput('secrets', JSON.stringify(env));
}).catch(error => core.setFailed('Fetch Failed! Error: ' + error.message));
}).catch(error => core.setFailed('Auth Failed! Error: ' + error.message));