Skip to content

feat: add post cleanup script to actions/setup to erase /tmp/gh-aw/#22938

Merged
pelikhan merged 12 commits intomainfrom
copilot/add-post-script-to-setup-action-again
Mar 25, 2026
Merged

feat: add post cleanup script to actions/setup to erase /tmp/gh-aw/#22938
pelikhan merged 12 commits intomainfrom
copilot/add-post-script-to-setup-action-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 25, 2026

Summary

Adds a post script to the actions/setup action that erases the /tmp/gh-aw/ directory after the job completes, using the runs.post lifecycle supported by JavaScript actions.

Changes

action.yml

  • Converts the action from using: composite to using: node20 to enable the runs.post lifecycle
  • Sets main: 'index.js', post: 'post.js', and post-if: 'always()' so the cleanup runs regardless of job outcome

index.js (new)

  • Thin Node.js wrapper that spawns setup.sh via child_process.spawnSync
  • Preserves all existing setup logic without modification
  • Explicitly normalises INPUT_SAFE_OUTPUT_CUSTOM_TOKENS to handle both hyphen and underscore forms of the env var name

post.js (new)

  • Runs in the post-job phase via runs.post
  • Removes /tmp/gh-aw/ using fs.rmSync with { recursive: true, force: true }
  • Logs a warning on failure but does not fail the job (cleanup is best-effort)

Notes

  • @actions/core is not used since the package lives in js/node_modules/ (a subdirectory) and is not in the module resolution path for files at the action root; built-in console and process are equivalent for this minimal wrapper pattern
  • The pre-existing lint warnings in node_modules/flatted (Go files inside npm deps) are unrelated to these changes


✨ PR Review Safe Output Test - Run 23556804478

Note

🔒 Integrity filter blocked 1 item

The following item were blocked because they don't meet the GitHub integrity level.

  • #22915 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

💥 [THE END] — Illustrated by Smoke Claude ·


Changeset

  • Type: patch
  • Description: Added post-job cleanup for actions/setup to remove /tmp/gh-aw/ and updated checkout handling so setup action runtime files remain available for post-step execution.

Generated by Changeset Generator for issue #22938 ·



✨ PR Review Safe Output Test - Run 23561682947

💥 [THE END] — Illustrated by Smoke Claude ·



✨ PR Review Safe Output Test - Run 23563803890

Note

🔒 Integrity filter blocked 2 items

The following items were blocked because they don't meet the GitHub integrity level.

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

💥 [THE END] — Illustrated by Smoke Claude ·



✨ PR Review Safe Output Test - Run 23566025032

💥 [THE END] — Illustrated by Smoke Claude ·

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4290b5c1-bc7e-4de0-b83d-22929f106bad
Copilot AI requested a review from pelikhan March 25, 2026 18:16
@pelikhan pelikhan marked this pull request as ready for review March 25, 2026 18:18
Copilot AI review requested due to automatic review settings March 25, 2026 18:18
@pelikhan pelikhan added the smoke label Mar 25, 2026
@github-actions
Copy link
Contributor

🔧 Starting tool validation... Agent Container Smoke Test is checking the agent container tools...

@github-actions
Copy link
Contributor

💥 WHOOSH! Smoke Claude springs into action on this pull request! [Panel 1 begins...]

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions github-actions bot removed the smoke label Mar 25, 2026
@github-actions
Copy link
Contributor

🔮 The ancient spirits stir... Smoke Codex awakens to divine this pull request...

Copy link
Contributor

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

Adds a post-job cleanup step to the actions/setup GitHub Action by converting it from a composite action to a JavaScript action, enabling runs.post to remove /tmp/gh-aw after the job completes.

Changes:

  • Convert actions/setup from using: composite to a Node-based action with main and post entrypoints.
  • Add index.js wrapper to invoke the existing setup.sh.
  • Add post.js to delete /tmp/gh-aw in the post-job phase.

Reviewed changes

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

File Description
actions/setup/action.yml Switches the action runtime to Node and wires up main/post scripts.
actions/setup/index.js Spawns setup.sh and normalizes one input env var.
actions/setup/post.js Best-effort post-job deletion of /tmp/gh-aw.

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

Comment on lines +15 to +20
const result = spawnSync(path.join(__dirname, "setup.sh"), [], {
stdio: "inherit",
env: Object.assign({}, process.env, {
INPUT_SAFE_OUTPUT_CUSTOM_TOKENS: safeOutputCustomTokens,
}),
});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

spawnSync is executing setup.sh directly. This relies on setup.sh having the executable bit set and being runnable on the host; previously the composite action (and test-setup-local.sh) invoked it via bash, which works even if the script isn't executable. To avoid EACCES failures and keep behavior consistent, invoke bash explicitly (e.g., spawn bash with the script path).

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +13
process.env["INPUT_SAFE_OUTPUT_CUSTOM_TOKENS"] ||
process.env["INPUT_SAFE-OUTPUT-CUSTOM-TOKENS"] ||
"false";
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The fallback lookup for process.env["INPUT_SAFE-OUTPUT-CUSTOM-TOKENS"] is likely dead code: GitHub Actions normalizes input env vars to use underscores, and environment variable names with hyphens are not generally settable/usable in shells. Consider removing this branch (or replace it with logic that normalizes from the actual input name) to reduce confusion.

Suggested change
process.env["INPUT_SAFE_OUTPUT_CUSTOM_TOKENS"] ||
process.env["INPUT_SAFE-OUTPUT-CUSTOM-TOKENS"] ||
"false";
process.env["INPUT_SAFE_OUTPUT_CUSTOM_TOKENS"] || "false";

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed — the hyphen-based env var lookup is unreachable since GitHub Actions always normalizes to underscores. Safe to remove that fallback branch.

📰 BREAKING: Report filed by Smoke Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

Note

🔒 Integrity filter blocked 1 item

The following item were blocked because they don't meet the GitHub integrity level.

  • #22915 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

💥 [THE END] — Illustrated by Smoke Claude

process.env["INPUT_SAFE-OUTPUT-CUSTOM-TOKENS"] ||
"false";

const result = spawnSync(path.join(__dirname, "setup.sh"), [], {
Copy link
Contributor

Choose a reason for hiding this comment

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

The spawnSync call looks good. Consider adding a timeout option to prevent the setup script from hanging indefinitely in edge cases.


try {
console.log(`Cleaning up ${tmpDir}...`);
fs.rmSync(tmpDir, { recursive: true, force: true });
Copy link
Contributor

Choose a reason for hiding this comment

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

Good use of recursive: true and force: true for cleanup. The best-effort approach (logging but not failing) is appropriate for post-job cleanup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed — the best-effort cleanup approach is the right call here. No need to fail the job over a temp dir cleanup. 🤖

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

Note

🔒 Integrity filter blocked 2 items

The following items were blocked because they don't meet the GitHub integrity level.

  • #22969 search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
  • #22938 pull_request_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".

To allow these resources, lower min-integrity in your GitHub frontmatter:

tools:
  github:
    min-integrity: approved  # merged | approved | unapproved | none

💥 [THE END] — Illustrated by Smoke Claude

@github-actions

This comment has been minimized.

@pelikhan
Copy link
Contributor

@copilot The cleanup session always fails with permissions issues.

Post job cleanup.
Cleaning up /tmp/gh-aw...
Warning: failed to clean up /tmp/gh-aw: EACCES, Permission denied: /tmp/gh-aw '/tmp/gh-aw'
https://github.com/github/gh-aw/actions/runs/23561682901

Files written by Docker containers or privileged scripts during the job
are owned by root, causing fs.rmSync to fail with EACCES. GitHub-hosted
runners have passwordless sudo, so try `sudo rm -rf` first and fall back
to fs.rmSync for self-hosted runners without sudo.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/4905a7a0-58f6-4f2f-b856-8cae909dc609

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 25, 2026

@copilot The cleanup session always fails with permissions issues.

Post job cleanup.
...

Fixed in d92b019. The files in /tmp/gh-aw/ are root-owned (written by Docker containers or privileged scripts), so fs.rmSync fails with EACCES. Updated post.js to use sudo rm -rf first (GitHub-hosted runners have passwordless sudo), with a fallback to fs.rmSync for self-hosted runners that don't have sudo but do have direct write access.

@pelikhan pelikhan added the smoke label Mar 25, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2026

✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready.

@github-actions
Copy link
Contributor

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions github-actions bot removed the smoke label Mar 25, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.53.0
jq 1.7
yq v4.52.4
curl 8.5.0
gh 2.87.3
node v20.20.1
python3 3.12.3
go 1.24.13
java 10.0.102
dotnet 10.0.102

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test ·

@github-actions
Copy link
Contributor

🧪 Smoke Test ResultsRun 23566025048

Test Result
GitHub MCP
MCP Scripts GH CLI
Serena MCP
Playwright
Web Fetch
File Writing
Bash Tool
Discussion Interaction
Build gh-aw
Discussion Creation
Workflow Dispatch
PR Review

Overall: ⚠️ PARTIAL PASS — Serena MCP tools not available. @pelikhan @Copilot

📰 BREAKING: Report filed by Smoke Copilot ·

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Reviewed the post-cleanup addition. Two inline notes on actions/setup/index.js: (1) invoke bash explicitly in spawnSync to avoid executable-bit issues; (2) the hyphenated INPUT_SAFE-OUTPUT-CUSTOM-TOKENS fallback is unreachable and can be removed. The core logic and the new post.js cleanup approach look good.

📰 BREAKING: Report filed by Smoke Copilot

process.env["INPUT_SAFE-OUTPUT-CUSTOM-TOKENS"] ||
"false";

const result = spawnSync(path.join(__dirname, "setup.sh"), [], {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider invoking bash explicitly instead of relying on the executable bit of setup.sh. This avoids potential EACCES errors if the script is not marked executable in the checkout:

spawnSync("bash", [path.join(__dirname, "setup.sh")], { ... })

// normalise the safe-output-custom-tokens input to ensure setup.sh finds it.
const safeOutputCustomTokens =
process.env["INPUT_SAFE_OUTPUT_CUSTOM_TOKENS"] ||
process.env["INPUT_SAFE-OUTPUT-CUSTOM-TOKENS"] ||
Copy link
Contributor

Choose a reason for hiding this comment

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

The INPUT_SAFE-OUTPUT-CUSTOM-TOKENS fallback (with hyphens) is unreachable in practice — GitHub Actions always normalizes input names to uppercase with underscores. The branch can be safely removed to simplify the code.

@github-actions
Copy link
Contributor

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@pelikhan pelikhan merged commit 65d34ef into main Mar 25, 2026
207 checks passed
@pelikhan pelikhan deleted the copilot/add-post-script-to-setup-action-again branch March 25, 2026 22:01
@github-actions
Copy link
Contributor

Smoke Test Run 23566025032

# Test Result
1 GitHub MCP (2 merged PRs)
2 MCP Scripts GH CLI (2 PRs)
3 Serena MCP (20+ symbols found)
4 Make Build
5 Playwright (GitHub.com)
6 Tavily Web Search
7 File Writing
8 Bash Tool
9 Discussion Interaction
10 Agentic Workflows MCP
11 Slack Safe Output
12 Update PR Body
13 PR Review Comments
14 Submit PR Review
15 Resolve Review Thread ⚠️
16 Add Reviewer
17 Push to PR Branch
18 Close PR ⚠️

Overall: PARTIAL — 16 passed, 2 skipped, 0 failed

💥 [THE END] — Illustrated by Smoke Claude ·

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

@@ -0,0 +1,5 @@
---
"gh-aw": patch
---
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit: the changeset description could mention that post-step cleanup requires the actions/setup directory to be included in sparse-checkout so the post script is available at runtime.

.github
.agents
actions/setup
sparse-checkout-cone-mode: true
Copy link
Contributor

Choose a reason for hiding this comment

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

Good addition — including actions/setup in sparse-checkout ensures the post.js script is available when GitHub Actions invokes the post step after the main job completes.

@github-actions
Copy link
Contributor

Smoke test summary (Codex, run 23566025025)

Merged PRs:

Results: GitHub MCP ✅ | Serena ✅ | Playwright ✅ | Web Fetch ✅ | File Write ✅ | Bash ✅ | Build ✅
Overall: PASS

🔮 The oracle has spoken through Smoke Codex ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants