Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ inputs:
description: "Extra headers to add to all requests sent to Infisical"
required: false
default: ""
env-prefix:
description: "Prefix to add to all exported environment variable names (e.g., 'TF_VAR_')"
required: false
default: ""
env-suffix:
description: "Suffix to add to all exported environment variable names"
required: false
default: ""
runs:
using: "node20"
main: "dist/index.cjs"
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const main = async () => {
const shouldIncludeImports = core.getBooleanInput("include-imports");
const shouldRecurse = core.getBooleanInput("recursive");
const extraHeaders = parseHeadersInput("extra-headers");
const envPrefix = core.getInput("env-prefix");
const envSuffix = core.getInput("env-suffix");

// get infisical token using credentials
let infisicalToken;
Expand Down Expand Up @@ -105,14 +107,18 @@ const main = async () => {
if (exportType === "env") {
// Write the secrets to action ENV
Object.entries(keyValueSecrets).forEach(([key, value]) => {
const prefixedKey = `${envPrefix}${key}${envSuffix}`;
core.setSecret(value);
core.exportVariable(key, value);
core.exportVariable(prefixedKey, value);
});
core.info("Injected secrets as environment variables");
} else if (exportType === "file") {
// Write the secrets to a file at the specified path
const fileContent = Object.keys(keyValueSecrets)
.map(key => `${key}='${keyValueSecrets[key]}'`)
.map(key => {
const prefixedKey = `${envPrefix}${key}${envSuffix}`;
return `${prefixedKey}='${keyValueSecrets[key]}'`;
})
.join("\n");

try {
Expand Down
Loading