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
5 changes: 5 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ inputs:
description: "Extra headers to add to all requests sent to Infisical"
required: false
default: ""
clean:
description: "If set to `true`, the exported .env file will be deleted after processing (clean up). Defaults to `true`"
required: false
default: "true"
runs:
using: "node20"
main: "dist/index.cjs"
post: "dist/post.cjs"
60 changes: 41 additions & 19 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,47 @@ import json from "@rollup/plugin-json";
import typescript from "@rollup/plugin-typescript";

/** @type {import('rollup').RollupOptions} */
const config = {
input: "src/index.ts",
output: {
esModule: false,
inlineDynamicImports: true,
file: "dist/index.cjs",
format: "cjs",
sourcemap: true,
banner: "#!/usr/bin/env node",
const config = [
{
input: "src/index.ts",
output: {
esModule: false,
inlineDynamicImports: true,
file: "dist/index.cjs",
format: "cjs",
sourcemap: true,
banner: "#!/usr/bin/env node",
},
plugins: [
typescript({
declaration: false,
tsconfig: "./tsconfig.json"
}),
commonjs(),
nodeResolve({ preferBuiltins: true }),
json()
],
},
plugins: [
typescript({
declaration: false,
tsconfig: "./tsconfig.json"
}),
commonjs(),
nodeResolve({ preferBuiltins: true }),
json()
],
}
{
input: "src/post.ts",
output: {
esModule: false,
inlineDynamicImports: true,
file: "dist/post.cjs",
format: "cjs",
sourcemap: true,
banner: "#!/usr/bin/env node",
},
plugins: [
typescript({
declaration: false,
tsconfig: "./tsconfig.json"
}),
commonjs(),
nodeResolve({ preferBuiltins: true }),
json()
],
}
];

export default config;
31 changes: 31 additions & 0 deletions src/post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import core from "@actions/core";
import fs from "fs/promises";

const post = async () => {
try {
const fileOutputPath = core.getInput("file-output-path");
const shouldClean = core.getBooleanInput("clean");

if (shouldClean) {
try {
const filePath = `${process.env.GITHUB_WORKSPACE}${fileOutputPath}`;

try {
await fs.access(filePath);
await fs.unlink(filePath);
core.info(`Cleaned up exported file at ${filePath}`);
} catch (accessErr) {
core.debug(`File not found at ${filePath}, skipping cleanup`);
}
} catch (err) {
core.warning(`Failed to clean up file: ${(err as Error)?.message}`);
Comment on lines +10 to +21
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These nested try-catch blocks are unnecessary and make the code harder to read. The inner try-catch (lines 13-19) already handles file access errors gracefully, so the outer try-catch (lines 10-22) that wraps it provides no additional value. Consider removing the outer try-catch block and keeping only the inner one.

Suggested change
try {
const filePath = `${process.env.GITHUB_WORKSPACE}${fileOutputPath}`;
try {
await fs.access(filePath);
await fs.unlink(filePath);
core.info(`Cleaned up exported file at ${filePath}`);
} catch (accessErr) {
core.debug(`File not found at ${filePath}, skipping cleanup`);
}
} catch (err) {
core.warning(`Failed to clean up file: ${(err as Error)?.message}`);
const filePath = `${process.env.GITHUB_WORKSPACE}${fileOutputPath}`;
try {
await fs.access(filePath);
await fs.unlink(filePath);
core.info(`Cleaned up exported file at ${filePath}`);
} catch (accessErr) {
core.debug(`File not found at ${filePath}, skipping cleanup`);

Copilot uses AI. Check for mistakes.
}
} else {
core.info("Cleanup is disabled, keeping exported file");
}
Comment on lines +9 to +25
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup logic should only execute when export-type is set to "file". Currently, the post script attempts to clean up the file regardless of the export type. When export-type is "env", no file is created (secrets are only set as environment variables in index.ts), so attempting cleanup is unnecessary and could log misleading debug messages. Add a check for export-type before attempting cleanup:

const exportType = core.getInput("export-type");
if (shouldClean && exportType === "file") {
  // cleanup logic
}

Copilot uses AI. Check for mistakes.
} catch (err) {
core.setFailed((err as Error)?.message);
}
};

post();
Loading