-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Add cleanup option for exported .env file and refactor post-processing logic #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…cessing logic (cherry picked from commit 789b609)
There was a problem hiding this 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
cleaninput parameter (defaults totrue) 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.
| 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}`); |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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.
| 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`); |
| 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"); | ||
| } |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
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
}
(cherry picked from commit 789b609)