Optimize publish workflow with path filtering and conditional steps#22
Optimize publish workflow with path filtering and conditional steps#22puccez wants to merge 2 commits into
Conversation
Add a lightweight 'changes' job using dorny/paths-filter to detect whether the push touches files that affect the published npm package. The 'publish' job now runs only when those files change, and the workflow itself is skipped at trigger time for doc-only / git metadata changes via paths-ignore.
Run install/test/typecheck/build on PRs to catch regressions before merge. The version bump and 'npm publish' steps are gated to push events on main, so PRs go through the same pipeline but never publish. Concurrency is now per-ref: PR runs cancel previous in-flight runs of the same PR, while main pushes still serialize without cancellation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57e2dc4b64
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| - name: Detect publishable changes | ||
| uses: dorny/paths-filter@v3 |
There was a problem hiding this comment.
Grant pull request read permission for path filtering
For pull_request runs, dorny/paths-filter fetches the PR file list through the GitHub API and its docs state that this mode requires pull-requests: read; because this workflow already specifies top-level permissions, GitHub sets every unspecified scope to none, so the new changes job will fail before PR validation can run. Add pull-requests: read at the workflow or changes job level while keeping the existing publish permissions.
Useful? React with 👍 / 👎.
Summary
Enhanced the npm publish GitHub Actions workflow to be more efficient by adding path-based filtering, conditional job execution, and improved concurrency handling. This prevents unnecessary workflow runs and publish attempts when only documentation or non-publishable files are modified.
Key Changes
paths-ignoreto skip workflow runs when only docs,.gitignore, or.gitkeepfiles are modified on push and pull requestschangesjob: Implemented a path filter detection job usingdorny/paths-filter@v3to identify publishable changes (source code, templates, config files, and workflow itself)publishjob dependent on thechangesjob and only runs when publishable changes are detectedcancel-in-progressto only apply for pull requestsSet next npm versionandPublish to npmsteps to only execute on main branch pushes (not pull requests)Implementation Details
changesjob outputs apublishableflag that indicates whether files affecting the package were modifiedsrc/,templates/,package.json,pnpm-lock.yaml,tsconfig.json,README.md,LICENSE, and the workflow file itselfhttps://claude.ai/code/session_01CeoFvkfEdfWNH5UGUH4Dxx