Skip to content

fix(ci): archive triage board cards when issues close - #1287

Merged
ascorbic merged 1 commit into
mainfrom
fix/triage-sync-remove-on-close
Jun 2, 2026
Merged

ascorbic merged 1 commit into
mainfrom
fix/triage-sync-remove-on-close

Conversation

@ascorbic

@ascorbic ascorbic commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

The triage-project-sync workflow mirrors an issue's triage state onto the Auto-Triage Projects v2 board, but it only ever added/updated cards on label changes, so closed issues stayed on the board forever. This makes board membership track open/closed state. No linked issue (maintainer-initiated CI fix).

How:

  • Adds closed and reopened to the issues trigger.
  • The add-vs-remove decision is keyed on the issue's open/closed state in the main loop: closing archives the card (reversible, leaves active board views but stays in the project archive); reopening unarchives + re-syncs from labels.
  • addProjectV2ItemById returns an existing item as-is, so the upsert path now calls unarchiveProjectV2Item explicitly, ensuring a reopened card returns to the active board.
  • Handling state in the loop (not only on the closed event) means label edits on already-closed issues and the manual workflow_dispatch backfill reconcile too, so the board self-heals to "open triaged issues only".
  • Card lookup matches on the project node id, not the per-owner project number (a foreign project that also happens to be fix: update create-emdash for standalone templates repo #3 can't be targeted).
  • The backfill loop is per-issue try/catch so one failure doesn't abort the batch; single-issue event runs still fail loudly via setFailed.

Archive (over hard delete) was chosen deliberately: it's reversible and preserves any card state, which matters given a recent destructive Projects v2 incident.

Safety: adversarial review pass; HIGH finding (project-number vs node-id match) and several MEDIUM findings (null guard, page-cap warning, resilient backfill loop) addressed. github-script JS syntax-checked, zizmor clean. Existing organization-projects: write token scope already covers archive/unarchive.

After merge, a one-shot workflow_dispatch run will archive the closed issues currently on the board.

Type of change

  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable)
  • I have added a changeset (if this PR changes a published package)
  • New features link to an approved Discussion

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 4.8 (via opencode). Adversarial review pass run with the same model family.

Screenshots / test output

zizmor --persona=regular reports no findings. YAML validated; embedded github-script syntax-checked with node --check (async-wrapped).


Try this PR

Open a fresh playground →

A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.

Tracks fix/triage-sync-remove-on-close. Updated automatically when the playground redeploys.

The triage project sync only added/updated cards on label changes; it
never removed them when an issue closed, so the Auto-Triage board
accumulated closed issues indefinitely.

Add `closed` and `reopened` to the issues trigger. The sync now keys the
add-vs-remove decision on the issue's open/closed state: closing archives
the card (reversible, leaves active board views, kept in the project
archive); reopening unarchives and re-syncs it from labels. Because
addProjectV2ItemById returns an existing item as-is, the upsert path
unarchives explicitly so a reopened card returns to the active board.

Handling state in the main loop (not only on the `closed` event) means
label edits on already-closed issues and the manual backfill reconcile
too, so the board self-heals to "open triaged issues only".

Card lookup matches on the project node id, not the per-owner project
number, so a foreign project that also happens to be #3 can't be
targeted. The backfill loop is per-issue try/catch so one failure does
not abort the batch; single-issue runs still fail loudly.
Copilot AI review requested due to automatic review settings June 2, 2026 12:36
@changeset-bot

changeset-bot Bot commented Jun 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 852e13b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
docs 852e13b Jun 02 2026, 12:33 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-playground 852e13b Jun 02 2026, 12:34 PM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
emdash-demo-cache 852e13b Jun 02 2026, 12:34 PM

@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@1287

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@1287

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@1287

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@1287

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@1287

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@1287

emdash

npm i https://pkg.pr.new/emdash@1287

create-emdash

npm i https://pkg.pr.new/create-emdash@1287

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@1287

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@1287

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@1287

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@1287

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@1287

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@1287

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@1287

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@1287

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@1287

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@1287

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@1287

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@1287

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@1287

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@1287

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@1287

commit: 852e13b

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the triage-project-sync GitHub Actions workflow so the Auto-Triage Projects v2 board stays consistent with issue lifecycle by archiving cards when issues close and restoring them when issues reopen.

Changes:

  • Expands the issues trigger to include closed and reopened.
  • Adds logic to archive the project card for closed issues and explicitly unarchive cards when re-adding/upserting reopened issues.
  • Improves safety/resilience with project-item matching by project node ID and per-issue error handling during workflow_dispatch backfills.

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

Comment on lines +226 to +230
// here -- rather than only on the `closed` event -- means label
// changes on an already-closed issue, and the dispatch backfill,
// also reconcile, so the board self-heals to "open triaged
// issues only". Reopening hits the else-branch with state "open"
// and is re-added below if it still carries triage labels.
Comment on lines +237 to +239
} catch (e) {
failures++;
core.warning(`#${iss.number}: sync failed: ${e.message}`);

@emdashbot emdashbot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR is a focused, well-scrubbed fix to the triage-project-sync workflow. The approach is sound: instead of letting closed issues linger on the triage board forever, the workflow now archives cards on close and unarchives them on reopen, using the same self-healing logic in the main loop so that label changes on already-closed issues and manual backfills also reconcile correctly.

I reviewed the diff line-by-line and traced the control flow for every event type (labeled, unlabeled, closed, reopened, workflow_dispatch). The key safety improvements all check out:

  • Node-ID matching in archiveCard avoids the per-owner project-number collision risk the author already identified.
  • projectItems(first:100) cap warning means a silently truncated result won’t hide a board-membership miss.
  • Per-issue try/catch in the backfill loop prevents one transient GraphQL failure from aborting the entire batch, while single-issue events still fail loudly via core.setFailed.
  • Unarchive before re-sync correctly handles the idempotent addProjectV2ItemById returning an existing archived item as-is.

Security posture is clean: all inputs reach GraphQL only as typed variables, there is no shell or template interpolation of untrusted data, and the least-privilege app-token scopes are unchanged.

There are no application-code changes (no SQL, API routes, UI, or migrations), so the AGENTS.md conventions that apply to product code are not in scope here. The PR checklist appropriately notes N/A for lint/typecheck/tests and correctly omits a changeset since no published package is touched.

No findings — this is ready to merge.

@github-actions github-actions Bot added review/approved Approved; no new commits since and removed review/needs-review No maintainer or bot review yet labels Jun 2, 2026
@ascorbic
ascorbic enabled auto-merge (squash) June 2, 2026 12:44
@ascorbic
ascorbic merged commit 54f7dc1 into main Jun 2, 2026
74 of 76 checks passed
@ascorbic
ascorbic deleted the fix/triage-sync-remove-on-close branch June 2, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants