Skip to content

Commit 6ed36b2

Browse files
CopilotMossaka
andcommitted
refactor: update JavaScript and shell scripts to use RUNNER_TEMP paths
Updates runtime JavaScript (.cjs) and shell (.sh) scripts to use process.env.RUNNER_TEMP and $RUNNER_TEMP instead of hardcoded /opt/gh-aw. Also adds write access validation for RUNNER_TEMP in setup.sh. Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
1 parent 9cc5215 commit 6ed36b2

32 files changed

+284
-279
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,8 @@ jobs:
825825
run: cd actions/setup/js && npm ci
826826
- name: Setup prompt templates for tests
827827
run: |
828-
mkdir -p /opt/gh-aw/prompts
829-
cp actions/setup/md/*.md /opt/gh-aw/prompts/
828+
mkdir -p ${{ runner.temp }}/gh-aw/prompts
829+
cp actions/setup/md/*.md ${{ runner.temp }}/gh-aw/prompts/
830830
- name: Run tests
831831
run: cd actions/setup/js && npm test
832832

.github/workflows/copilot-maintenance.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
GH_AW_REQUIRED_ROLES: "admin"
4242
with:
4343
script: |
44-
const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs');
44+
const { setupGlobals } = require('${{ runner.temp }}/gh-aw/actions/setup_globals.cjs');
4545
setupGlobals(core, github, context, exec, io);
46-
const { checkRepositoryPermission } = require('/opt/gh-aw/actions/check_permissions_utils.cjs');
46+
const { checkRepositoryPermission } = require('${{ runner.temp }}/gh-aw/actions/check_permissions_utils.cjs');
4747
4848
const actor = context.actor;
4949
const { owner, repo } = context.repo;

.github/workflows/smoke-claude.lock.yml

Lines changed: 107 additions & 107 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

actions/setup/js/check_workflow_recompile_needed.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async function main() {
128128

129129
// Read the issue template from the prompts directory
130130
// Allow override via environment variable for testing
131-
const promptsDir = process.env.GH_AW_PROMPTS_DIR || "/opt/gh-aw/prompts";
131+
const promptsDir = process.env.GH_AW_PROMPTS_DIR || `${process.env.RUNNER_TEMP}/gh-aw/prompts`;
132132
const templatePath = `${promptsDir}/workflow_recompile_issue.md`;
133133
let issueTemplate;
134134
try {

actions/setup/js/checkout_pr_branch.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Pull request #${pullRequest.number} is closed. The checkout failed because the b
276276
core.setOutput("checkout_pr_success", "false");
277277

278278
// Load and render step summary template
279-
const templatePath = "/opt/gh-aw/prompts/pr_checkout_failure.md";
279+
const templatePath = `${process.env.RUNNER_TEMP}/gh-aw/prompts/pr_checkout_failure.md`;
280280
const template = fs.readFileSync(templatePath, "utf8");
281281
const summaryContent = renderTemplate(template, {
282282
error_message: errorMsg,

actions/setup/js/collect_ndjson_output.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function main() {
1717
const { resolveAllowedMentionsFromPayload } = require("./resolve_mentions_from_payload.cjs");
1818

1919
// Load validation config from file and set it in environment for the validator to read
20-
const validationConfigPath = process.env.GH_AW_VALIDATION_CONFIG_PATH || "/opt/gh-aw/safeoutputs/validation.json";
20+
const validationConfigPath = process.env.GH_AW_VALIDATION_CONFIG_PATH || `${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/validation.json`;
2121
let validationConfig = null;
2222
try {
2323
if (fs.existsSync(validationConfigPath)) {
@@ -155,7 +155,7 @@ async function main() {
155155
}
156156
const outputFile = process.env.GH_AW_SAFE_OUTPUTS;
157157
// Read config from file instead of environment variable
158-
const configPath = process.env.GH_AW_SAFE_OUTPUTS_CONFIG_PATH || "/opt/gh-aw/safeoutputs/config.json";
158+
const configPath = process.env.GH_AW_SAFE_OUTPUTS_CONFIG_PATH || `${process.env.RUNNER_TEMP}/gh-aw/safeoutputs/config.json`;
159159
let safeOutputsConfig;
160160
core.info(`[INGESTION] Reading config from: ${configPath}`);
161161
try {

actions/setup/js/create_issue.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function createParentIssueTemplate(groupId, titlePrefix, workflowName, workflowS
177177
const title = applyTitlePrefix(`${groupId} - Issue Group`, titlePrefix);
178178

179179
// Load issue template
180-
const issueTemplatePath = "/opt/gh-aw/prompts/issue_group_parent.md";
180+
const issueTemplatePath = `${process.env.RUNNER_TEMP}/gh-aw/prompts/issue_group_parent.md`;
181181
const issueTemplate = fs.readFileSync(issueTemplatePath, "utf8");
182182

183183
// Create template context

actions/setup/js/create_missing_data_issue.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const main = buildMissingIssueHandler({
2020
defaultTitlePrefix: "[missing data]",
2121
defaultLabels: ["agentic-workflows"],
2222
itemsField: "missing_data",
23-
templatePath: "/opt/gh-aw/prompts/missing_data_issue.md",
23+
templatePath: `${process.env.RUNNER_TEMP}/gh-aw/prompts/missing_data_issue.md`,
2424
templateListKey: "missing_data_list",
2525
buildCommentHeader: runUrl => [`## Missing Data Reported`, ``, `The following data was reported as missing during [workflow run](${runUrl}):`, ``],
2626
renderCommentItem: (item, index) => {

actions/setup/js/create_missing_tool_issue.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const main = buildMissingIssueHandler({
2020
defaultTitlePrefix: "[missing tool]",
2121
defaultLabels: ["agentic-workflows"],
2222
itemsField: "missing_tools",
23-
templatePath: "/opt/gh-aw/prompts/missing_tool_issue.md",
23+
templatePath: `${process.env.RUNNER_TEMP}/gh-aw/prompts/missing_tool_issue.md`,
2424
templateListKey: "missing_tools_list",
2525
buildCommentHeader: runUrl => [`## Missing Tools Reported`, ``, `The following tools were reported as missing during [workflow run](${runUrl}):`, ``],
2626
renderCommentItem: (tool, index) => {

actions/setup/js/create_pull_request.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ ${patchPreview}`;
957957
// Use the push-failed template with artifact download instructions.
958958
const runId = context.runId;
959959
const patchFileName = patchFilePath ? patchFilePath.replace("/tmp/gh-aw/", "") : "aw-unknown.patch";
960-
const pushFailedTemplatePath = "/opt/gh-aw/prompts/manifest_protection_push_failed_fallback.md";
960+
const pushFailedTemplatePath = `${process.env.RUNNER_TEMP}/gh-aw/prompts/manifest_protection_push_failed_fallback.md`;
961961
const pushFailedTemplate = fs.readFileSync(pushFailedTemplatePath, "utf8");
962962
fallbackBody = renderTemplate(pushFailedTemplate, {
963963
body,
@@ -975,7 +975,7 @@ ${patchPreview}`;
975975
const encodedBase = baseBranch.split("/").map(encodeURIComponent).join("/");
976976
const encodedHead = branchName.split("/").map(encodeURIComponent).join("/");
977977
const createPrUrl = `${githubServer}/${repoParts.owner}/${repoParts.repo}/compare/${encodedBase}...${encodedHead}?expand=1&title=${encodeURIComponent(title)}`;
978-
const templatePath = "/opt/gh-aw/prompts/manifest_protection_create_pr_fallback.md";
978+
const templatePath = `${process.env.RUNNER_TEMP}/gh-aw/prompts/manifest_protection_create_pr_fallback.md`;
979979
const template = fs.readFileSync(templatePath, "utf8");
980980
fallbackBody = renderTemplate(template, {
981981
body,

0 commit comments

Comments
 (0)