Skip to content

Commit 2f80543

Browse files
Copilotpelikhan
andcommitted
fix: remove campaign_discovery.cjs and inline logic in campaign workflow
Co-authored-by: pelikhan <[email protected]>
1 parent 0803979 commit 2f80543

4 files changed

Lines changed: 57 additions & 212 deletions

File tree

.github/workflows/security-alert-burndown.campaign.g.lock.yml

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

.github/workflows/security-alert-burndown.campaign.g.md

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,58 @@ steps:
5757
with:
5858
github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
5959
script: |
60-
61-
const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs');
62-
setupGlobals(core, github, context, exec, io);
63-
const { main } = require('/opt/gh-aw/actions/campaign_discovery.cjs');
64-
await main();
60+
const fs = require("fs");
61+
const path = require("path");
62+
63+
const campaignId = process.env.GH_AW_CAMPAIGN_ID;
64+
const trackerLabel = process.env.GH_AW_TRACKER_LABEL;
65+
const discoveryRepos = process.env.GH_AW_DISCOVERY_REPOS;
66+
const cursorPath = process.env.GH_AW_CURSOR_PATH;
67+
const maxItems = parseInt(process.env.GH_AW_MAX_DISCOVERY_ITEMS ?? "50", 10);
68+
const maxPages = parseInt(process.env.GH_AW_MAX_DISCOVERY_PAGES ?? "3", 10);
69+
const projectUrl = process.env.GH_AW_PROJECT_URL;
70+
const workflows = (process.env.GH_AW_WORKFLOWS ?? "").split(",").map(w => w.trim()).filter(Boolean);
71+
72+
if (!campaignId || !trackerLabel || !discoveryRepos) {
73+
core.setFailed("Missing required environment variables: GH_AW_CAMPAIGN_ID, GH_AW_TRACKER_LABEL, GH_AW_DISCOVERY_REPOS");
74+
return;
75+
}
76+
77+
const repos = discoveryRepos.split(",").map(r => r.trim()).filter(Boolean);
78+
const allItems = [];
79+
80+
for (const repoPath of repos) {
81+
const parts = repoPath.split("/");
82+
if (parts.length !== 2) { core.warning(`Invalid repo format: "${repoPath}" — skipping`); continue; }
83+
const [owner, repo] = parts;
84+
let page = 1;
85+
while (page <= maxPages && allItems.length < maxItems) {
86+
const perPage = Math.min(30, maxItems - allItems.length);
87+
try {
88+
const response = await github.rest.issues.listForRepo({ owner, repo, labels: trackerLabel, state: "all", sort: "updated", direction: "desc", per_page: perPage, page });
89+
if (response.data.length === 0) break;
90+
for (const item of response.data) {
91+
if (allItems.length >= maxItems) break;
92+
allItems.push({ id: item.id, number: item.number, title: item.title, state: item.state, html_url: item.html_url, created_at: item.created_at, updated_at: item.updated_at, labels: item.labels.map(l => typeof l === "string" ? l : (l.name ?? "")), repo: `${owner}/${repo}`, is_pr: !!item.pull_request });
93+
}
94+
if (response.data.length < perPage) break;
95+
page++;
96+
} catch (err) { core.error(`Failed to search ${owner}/${repo} page ${page}: ${err.message}`); break; }
97+
}
98+
}
99+
100+
const GH_AW_TMP_DIR = "/tmp/gh-aw";
101+
const discoveryOutputPath = path.join(GH_AW_TMP_DIR, "campaign-discovery.json");
102+
const discoveryData = { campaign_id: campaignId, timestamp: new Date().toISOString(), tracker_label: trackerLabel, project_url: projectUrl, workflows, items_count: allItems.length, items: allItems };
103+
try {
104+
fs.mkdirSync(GH_AW_TMP_DIR, { recursive: true });
105+
fs.writeFileSync(discoveryOutputPath, JSON.stringify(discoveryData, null, 2));
106+
} catch (err) { core.warning(`Failed to write discovery data: ${err.message}`); }
107+
108+
core.setOutput("items_count", String(allItems.length));
109+
core.setOutput("campaign_id", campaignId);
110+
core.setOutput("discovery_file", discoveryOutputPath);
111+
core.info(`✓ Campaign discovery complete: ${allItems.length} item(s) found for campaign "${campaignId}"`);
65112
---
66113

67114
<!-- This file was automatically generated by gh-aw. DO NOT EDIT. -->

actions/setup/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This action copies workflow script files to the agent environment.
77
This action runs in all workflow jobs to provide scripts that can be used instead of being inlined in the workflow. This includes scripts for activation jobs, agent jobs, and safe-output jobs.
88

99
The action copies:
10-
- 117 `.cjs` JavaScript files from the `js/` directory
10+
- 226 `.cjs` JavaScript files from the `js/` directory
1111
- 7 `.sh` shell scripts from the `sh/` directory
1212

1313
All files are copied to the destination directory (default: `/tmp/gh-aw/actions`). These files are generated by running `make actions-build` and are committed to the repository.
@@ -35,7 +35,7 @@ Default: `/tmp/gh-aw/actions`
3535

3636
### `files-copied`
3737

38-
The number of files copied to the destination directory (should be 124: 117 JavaScript files + 7 shell scripts).
38+
The number of files copied to the destination directory (should be 233: 226 JavaScript files + 7 shell scripts).
3939

4040
## Example
4141

@@ -56,7 +56,7 @@ steps:
5656

5757
This action copies files from `actions/setup/`, including:
5858

59-
### JavaScript Files (117 files from `js/`)
59+
### JavaScript Files (226 files from `js/`)
6060
- Activation job scripts (check_stop_time, check_skip_if_match, check_command_position, etc.)
6161
- Agent job scripts (compute_text, create_issue, create_pull_request, etc.)
6262
- Safe output scripts (safe_outputs_*, safe_inputs_*, messages, etc.)

actions/setup/js/campaign_discovery.cjs

Lines changed: 0 additions & 197 deletions
This file was deleted.

0 commit comments

Comments
 (0)