feat(blog): auto-update project board on publish#693
Conversation
GITHUB_TOKEN lacks admin permissions to merge PRs that require approving reviews. Use GH_PAT (already available as repo secret) for both checkout and PR merge. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The "Create and merge PR" step was running even when the article was already published, causing failures with empty branch/slug vars. Now gates on publish step outputs being set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Uses existing pipeline helpers (getProjectItems, updateCardStatus) to find the card by article path and move it to Published status. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR extends the Key changes:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
actor Dev as Developer
participant WD as workflow_dispatch
participant GHA as GitHub Actions
participant FS as File System
participant GH as GitHub API (GH_PAT)
participant PB as Project Board V2
Dev->>WD: Trigger (slug or empty)
WD->>GHA: Start publish job
GHA->>FS: Resolve article path (by slug or oldest draft)
FS-->>GHA: article path
GHA->>FS: Update frontmatter status → published
GHA->>GH: git push new branch
GHA->>GH: gh pr create + merge (squash, admin)
GH-->>GHA: PR merged ✓
GHA->>GHA: actions/setup-node@v4 (Node 20)
GHA->>PB: getProjectItems() via gh project item-list
PB-->>GHA: items[]
GHA->>GHA: find card where articlePath == ARTICLE
alt card found
GHA->>PB: updateCardStatus(card.id, 'published')
PB-->>GHA: ✓ Card moved to Published
else card not found
GHA->>GHA: log warning, continue
end
Prompt To Fix All With AIThis is a comment left during a code review.
Path: .github/workflows/blog-publish.yml
Line: 122-132
Comment:
**`node -e` ignores `"type": "module"` — ESM import will fail**
The inline script uses `import` (ESM) syntax, but `node -e` always runs in CommonJS mode regardless of the `"type": "module"` setting in `blog/pipeline/package.json`. Node.js only applies that file to disk-based `.js` files, not to `--eval`/`-e` input. At runtime this will throw:
```
SyntaxError: Cannot use import statement in an interactive module
```
The fix is to pass `--input-type=module` so Node treats the inline script as ESM:
```suggestion
node --input-type=module -e "
import { getProjectItems, updateCardStatus } from './project.js';
const items = getProjectItems();
const card = items.find(i => i.articlePath === process.env.ARTICLE);
if (card) {
updateCardStatus(card.id, 'published');
console.log('Updated card to Published:', card.title);
} else {
console.log('No project card found for article:', process.env.ARTICLE);
}
"
```
Alternatively, write a small `update-status.js` script and invoke it with `node update-status.js` to avoid the flag entirely.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: .github/workflows/blog-publish.yml
Line: 110-113
Comment:
**Missing `npm install` step**
`actions/setup-node@v4` installs the Node.js runtime but does not install npm dependencies. While `project.js` itself only uses Node built-ins (`child_process`) and the local `config.js`, the `package.json` in `blog/pipeline` lists `google-trends-api` and `rss-parser` as dependencies. If any transitive import in the module graph (e.g. a future change to `config.js`) pulls in an npm package, this step will silently break.
Consider adding an explicit install step so the environment is fully reproduced:
```yaml
- uses: actions/setup-node@v4
if: steps.publish.outputs.slug != ''
with:
node-version: 20
- name: Install pipeline dependencies
if: steps.publish.outputs.slug != ''
run: npm ci --prefix blog/pipeline
```
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 7c6ba54 |
| node -e " | ||
| import { getProjectItems, updateCardStatus } from './project.js'; | ||
| const items = getProjectItems(); | ||
| const card = items.find(i => i.articlePath === process.env.ARTICLE); | ||
| if (card) { | ||
| updateCardStatus(card.id, 'published'); | ||
| console.log('Updated card to Published:', card.title); | ||
| } else { | ||
| console.log('No project card found for article:', process.env.ARTICLE); | ||
| } | ||
| " |
There was a problem hiding this comment.
node -e ignores "type": "module" — ESM import will fail
The inline script uses import (ESM) syntax, but node -e always runs in CommonJS mode regardless of the "type": "module" setting in blog/pipeline/package.json. Node.js only applies that file to disk-based .js files, not to --eval/-e input. At runtime this will throw:
SyntaxError: Cannot use import statement in an interactive module
The fix is to pass --input-type=module so Node treats the inline script as ESM:
| node -e " | |
| import { getProjectItems, updateCardStatus } from './project.js'; | |
| const items = getProjectItems(); | |
| const card = items.find(i => i.articlePath === process.env.ARTICLE); | |
| if (card) { | |
| updateCardStatus(card.id, 'published'); | |
| console.log('Updated card to Published:', card.title); | |
| } else { | |
| console.log('No project card found for article:', process.env.ARTICLE); | |
| } | |
| " | |
| node --input-type=module -e " | |
| import { getProjectItems, updateCardStatus } from './project.js'; | |
| const items = getProjectItems(); | |
| const card = items.find(i => i.articlePath === process.env.ARTICLE); | |
| if (card) { | |
| updateCardStatus(card.id, 'published'); | |
| console.log('Updated card to Published:', card.title); | |
| } else { | |
| console.log('No project card found for article:', process.env.ARTICLE); | |
| } | |
| " |
Alternatively, write a small update-status.js script and invoke it with node update-status.js to avoid the flag entirely.
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/blog-publish.yml
Line: 122-132
Comment:
**`node -e` ignores `"type": "module"` — ESM import will fail**
The inline script uses `import` (ESM) syntax, but `node -e` always runs in CommonJS mode regardless of the `"type": "module"` setting in `blog/pipeline/package.json`. Node.js only applies that file to disk-based `.js` files, not to `--eval`/`-e` input. At runtime this will throw:
```
SyntaxError: Cannot use import statement in an interactive module
```
The fix is to pass `--input-type=module` so Node treats the inline script as ESM:
```suggestion
node --input-type=module -e "
import { getProjectItems, updateCardStatus } from './project.js';
const items = getProjectItems();
const card = items.find(i => i.articlePath === process.env.ARTICLE);
if (card) {
updateCardStatus(card.id, 'published');
console.log('Updated card to Published:', card.title);
} else {
console.log('No project card found for article:', process.env.ARTICLE);
}
"
```
Alternatively, write a small `update-status.js` script and invoke it with `node update-status.js` to avoid the flag entirely.
How can I resolve this? If you propose a fix, please make it concise.
Moves the project card from Drafting to Published when the publish workflow runs.