Skip to content

Commit

Permalink
core logs
Browse files Browse the repository at this point in the history
  • Loading branch information
manquer committed Sep 16, 2024
1 parent 45a6120 commit bb5114b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82083,6 +82083,7 @@ var keyvault_secrets_dist = __nccwpck_require__(181);




class KeyVaultClient {
static #instance;
#client;
Expand All @@ -82101,11 +82102,12 @@ class KeyVaultClient {
const k = key.replace(/_/g, '-');
const secret = await this.#client.getSecret(`${prefix}-${k}`);
value = (0,lodash.get)(secret, 'value');
core.info(value);
if (!value)
throw new Error(`Secret ${k} not found in service ${prefix}`);
this.#keys = (0,lodash.set)(this.#keys, key, value);
}
console.log(value);
core.info(value);
return value;
}
}
Expand All @@ -82115,6 +82117,7 @@ class KeyVaultClient {




async function setup(prefix) {
const items = (0,lodash.filter)(Object.keys(process.env), (i) => (0,lodash.startsWith)(i, `${prefix}_`));
const res = await PromiseExtended.map(items, async (k) => {
Expand All @@ -82124,10 +82127,10 @@ async function setup(prefix) {
console.log(value);
return `\n${key}=${value}`;
});
console.log(res);
core.info(res.toString());
const env = (0,lodash.reduce)(res, (acc, i) => `${acc}${i}`);
const current = process.env.GITHUB_ENV;
console.log(env);
core.info(env);
process.env.GITHUB_ENV = `${current}${env}`;
}

Expand Down
5 changes: 3 additions & 2 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { reduce, filter, startsWith } from 'lodash'
import * as core from '@actions/core'
import { PromiseExtended } from './promise'
import Kv from './kv'
export async function setup(prefix: string): Promise<void> {
Expand All @@ -10,9 +11,9 @@ export async function setup(prefix: string): Promise<void> {
console.log(value)
return `\n${key}=${value}`
})
console.log(res)
core.info(res.toString())
const env = reduce(res, (acc, i) => `${acc}${i}`)
const current = process.env.GITHUB_ENV
console.log(env)
core.info(env)
process.env.GITHUB_ENV = `${current}${env}`
}
4 changes: 3 additions & 1 deletion src/kv.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DefaultAzureCredential } from '@azure/identity'
import { type KeyVaultSecret, SecretClient } from '@azure/keyvault-secrets'
import { get, set } from 'lodash'
import * as core from '@actions/core'

export class KeyVaultClient {
static #instance: KeyVaultClient
Expand All @@ -23,10 +24,11 @@ export class KeyVaultClient {
const k = key.replace(/_/g, '-')
const secret: KeyVaultSecret = await this.#client.getSecret(`${prefix}-${k}`)
value = get(secret, 'value')
core.info(value)
if (!value) throw new Error(`Secret ${k} not found in service ${prefix}`)
this.#keys = set(this.#keys, key, value)
}
console.log(value)
core.info(value)
return value
}
}
Expand Down

0 comments on commit bb5114b

Please sign in to comment.