Skip to content

Commit

Permalink
bundle cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
manquer committed Sep 16, 2024
1 parent c6ece87 commit e1e41bf
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
8 changes: 1 addition & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82105,14 +82105,13 @@ class KeyVaultClient {
let value = (0,lodash.get)(this.#keys, key); // in memory cache
if (!value) {
const k = key.replace(/_/g, '-');
core.info(`fetching... ${k}`);
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);
}
core.info(value);
return value;
}
}
Expand All @@ -82122,20 +82121,15 @@ 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) => {
const key = k.split(`${prefix}_`)[1];
console.log(key);
const value = await kv.getSecret(prefix, key);
console.log(value);
return `\n${key}=${value}`;
});
core.info(res.toString());
const env = (0,lodash.reduce)(res, (acc, i) => `${acc}${i}`);
const current = process.env.GITHUB_ENV;
core.info(env);
process.env.GITHUB_ENV = `${current}${env}`;
}

Expand Down
5 changes: 0 additions & 5 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
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> {
const items = filter(Object.keys(process.env), (i: string) => startsWith(i, `${prefix}_`))
const res = await PromiseExtended.map(items, async (k: string): Promise<string> => {
const key = k.split(`${prefix}_`)[1]
console.log(key)
const value: string = await Kv.getSecret(prefix, key)
console.log(value)
return `\n${key}=${value}`
})
core.info(res.toString())
const env = reduce(res, (acc, i) => `${acc}${i}`)
const current = process.env.GITHUB_ENV
core.info(env)
process.env.GITHUB_ENV = `${current}${env}`
}
3 changes: 1 addition & 2 deletions src/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ export class KeyVaultClient {
let value = get(this.#keys, key) // in memory cache
if (!value) {
const k = key.replace(/_/g, '-')
core.info(`fetching... ${k}`)
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)
}
core.info(value)
return value
}
}
Expand Down

0 comments on commit e1e41bf

Please sign in to comment.