Skip to content

Conversation

@mertemr
Copy link

@mertemr mertemr commented Nov 12, 2025

(cherry picked from commit 789b609)

Copilot AI review requested due to automatic review settings November 12, 2025 22:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new cleanup feature that automatically deletes exported .env files after the GitHub Action workflow completes. The implementation introduces a post-execution script that runs after the main action finishes.

Key changes:

  • Adds a new clean input parameter (defaults to true) to control whether exported .env files should be deleted
  • Implements a post-processing script (post.ts) that handles file cleanup
  • Updates the build configuration to compile both main and post scripts

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/post.ts New post-processing script that handles cleanup of exported .env files based on the clean input parameter
rollup.config.js Refactored from single build config to array of configs to support building both main and post scripts
action.yaml Added new clean input parameter and configured the post-processing hook to run dist/post.cjs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +21
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}`);
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.
Comment on lines +9 to +25
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}`);
}
} else {
core.info("Cleanup is disabled, keeping exported file");
}
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant