-
Notifications
You must be signed in to change notification settings - Fork 295
fix: inline campaign discovery logic in campaign workflow step #20109
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -57,11 +57,58 @@ steps: | |||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||
| github-token: ${{ secrets.GH_AW_GITHUB_MCP_SERVER_TOKEN || secrets.GH_AW_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); | ||||||||||||||||||||||||||||||||||||||||||||||
| setupGlobals(core, github, context, exec, io); | ||||||||||||||||||||||||||||||||||||||||||||||
| const { main } = require('/opt/gh-aw/actions/campaign_discovery.cjs'); | ||||||||||||||||||||||||||||||||||||||||||||||
| await main(); | ||||||||||||||||||||||||||||||||||||||||||||||
| const fs = require("fs"); | ||||||||||||||||||||||||||||||||||||||||||||||
| const path = require("path"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const campaignId = process.env.GH_AW_CAMPAIGN_ID; | ||||||||||||||||||||||||||||||||||||||||||||||
| const trackerLabel = process.env.GH_AW_TRACKER_LABEL; | ||||||||||||||||||||||||||||||||||||||||||||||
| const discoveryRepos = process.env.GH_AW_DISCOVERY_REPOS; | ||||||||||||||||||||||||||||||||||||||||||||||
| const cursorPath = process.env.GH_AW_CURSOR_PATH; | ||||||||||||||||||||||||||||||||||||||||||||||
| const maxItems = parseInt(process.env.GH_AW_MAX_DISCOVERY_ITEMS ?? "50", 10); | ||||||||||||||||||||||||||||||||||||||||||||||
| const maxPages = parseInt(process.env.GH_AW_MAX_DISCOVERY_PAGES ?? "3", 10); | ||||||||||||||||||||||||||||||||||||||||||||||
| const projectUrl = process.env.GH_AW_PROJECT_URL; | ||||||||||||||||||||||||||||||||||||||||||||||
| const workflows = (process.env.GH_AW_WORKFLOWS ?? "").split(",").map(w => w.trim()).filter(Boolean); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (!campaignId || !trackerLabel || !discoveryRepos) { | ||||||||||||||||||||||||||||||||||||||||||||||
| core.setFailed("Missing required environment variables: GH_AW_CAMPAIGN_ID, GH_AW_TRACKER_LABEL, GH_AW_DISCOVERY_REPOS"); | ||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const repos = discoveryRepos.split(",").map(r => r.trim()).filter(Boolean); | ||||||||||||||||||||||||||||||||||||||||||||||
| const allItems = []; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| for (const repoPath of repos) { | ||||||||||||||||||||||||||||||||||||||||||||||
| const parts = repoPath.split("/"); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (parts.length !== 2) { core.warning(`Invalid repo format: "${repoPath}" — skipping`); continue; } | ||||||||||||||||||||||||||||||||||||||||||||||
| const [owner, repo] = parts; | ||||||||||||||||||||||||||||||||||||||||||||||
| let page = 1; | ||||||||||||||||||||||||||||||||||||||||||||||
| while (page <= maxPages && allItems.length < maxItems) { | ||||||||||||||||||||||||||||||||||||||||||||||
| const perPage = Math.min(30, maxItems - allItems.length); | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| const response = await github.rest.issues.listForRepo({ owner, repo, labels: trackerLabel, state: "all", sort: "updated", direction: "desc", per_page: perPage, page }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+79
to
+88
|
||||||||||||||||||||||||||||||||||||||||||||||
| for (const repoPath of repos) { | |
| const parts = repoPath.split("/"); | |
| if (parts.length !== 2) { core.warning(`Invalid repo format: "${repoPath}" — skipping`); continue; } | |
| const [owner, repo] = parts; | |
| let page = 1; | |
| while (page <= maxPages && allItems.length < maxItems) { | |
| const perPage = Math.min(30, maxItems - allItems.length); | |
| try { | |
| const response = await github.rest.issues.listForRepo({ owner, repo, labels: trackerLabel, state: "all", sort: "updated", direction: "desc", per_page: perPage, page }); | |
| let pagesUsed = 0; | |
| for (const repoPath of repos) { | |
| const parts = repoPath.split("/"); | |
| if (parts.length !== 2) { core.warning(`Invalid repo format: "${repoPath}" — skipping`); continue; } | |
| const [owner, repo] = parts; | |
| let page = 1; | |
| while (allItems.length < maxItems && pagesUsed < maxPages) { | |
| const perPage = Math.min(30, maxItems - allItems.length); | |
| try { | |
| const response = await github.rest.issues.listForRepo({ owner, repo, labels: trackerLabel, state: "all", sort: "updated", direction: "desc", per_page: perPage, page }); | |
| pagesUsed++; |
Copilot
AI
Mar 8, 2026
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.
If writing campaign-discovery.json fails, the step only logs a warning but still sets discovery_file to the (potentially non-existent) path and continues as success. Since downstream logic expects this file to exist, this should fail the step (e.g., core.setFailed(...) / rethrow) when the directory creation or write fails, or otherwise guarantee the file exists before setting outputs.
| } catch (err) { core.warning(`Failed to write discovery data: ${err.message}`); } | |
| } catch (err) { | |
| core.setFailed(`Failed to write discovery data: ${err.message}`); | |
| return; | |
| } |
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.
cursorPathis read fromGH_AW_CURSOR_PATHbut never used, and the discovery step does a full rescan every run. This conflicts with the workflow’s own instructions to use a durable cursor/checkpoint to avoid rescanning and to update the cursor file each run. Please either implement read/write of the cursor atcursorPath(e.g., boundary onupdated_at+ tie-breaker) or remove the cursor env var and the incremental-discovery requirements if they’re no longer applicable.