From 7c8d77549057738437a7945a7d3f8c3bdc198977 Mon Sep 17 00:00:00 2001 From: Mani Ka Date: Mon, 16 Sep 2024 02:17:56 -0700 Subject: [PATCH] Custom prefix --- .github/workflows/release.yml | 2 +- dist/index.js | 4 ++-- src/env.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da14e37..a6b0c28 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: with: SERVICE_PREFIX: DEFAULT env: - DEFAULT_TEST_KEY: DEFAULT_TEST_KEY + KV_TEST_KEY: DEFAULT_TEST_KEY AZURE_CLIENT_ID: 6b37a34b-4496-47e2-ab31-1bc31926e797 AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} AZURE_TENANT_ID: 5a7d1f14-292f-4043-a73a-d0339418a1e1 diff --git a/dist/index.js b/dist/index.js index 8a856a1..fb5eefe 100644 --- a/dist/index.js +++ b/dist/index.js @@ -82123,9 +82123,9 @@ class KeyVaultClient { async function setup(prefix) { - const items = (0,lodash.filter)(Object.keys(process.env), (i) => (0,lodash.startsWith)(i, `${prefix}_`)); + const items = (0,lodash.filter)(Object.keys(process.env), (i) => (0,lodash.startsWith)(i, `${prefix}_`) || (0,lodash.startsWith)(i, `KV_`)); await PromiseExtended.map(items, async (k) => { - const key = k.split(`${prefix}_`)[1]; + const key = (0,lodash.get)(k.split(`${prefix}_`), '1') || (0,lodash.get)(k.split(`KV_`), '1'); const value = await kv.getSecret(prefix, key); core.exportVariable(key, value); core.setSecret(`${value}`); diff --git a/src/env.ts b/src/env.ts index 25abd51..a9b35c8 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,12 +1,12 @@ -import { filter, startsWith } from 'lodash' +import { filter, startsWith, get } from 'lodash' import * as core from '@actions/core' import { PromiseExtended } from './promise' import Kv from './kv' export async function setup(prefix: string): Promise { - const items = filter(Object.keys(process.env), (i: string) => startsWith(i, `${prefix}_`)) + const items = filter(Object.keys(process.env), (i: string) => startsWith(i, `${prefix}_`) || startsWith(i, `KV_`)) await PromiseExtended.map(items, async (k: string): Promise => { - const key = k.split(`${prefix}_`)[1] + const key = get(k.split(`${prefix}_`), '1') || get(k.split(`KV_`), '1') const value: string = await Kv.getSecret(prefix, key) core.exportVariable(key, value) core.setSecret(`${value}`)