Skip to content

Optimize publish workflow with path filtering and conditional steps#22

Open
puccez wants to merge 2 commits into
mainfrom
claude/skip-build-no-changes-lu85A
Open

Optimize publish workflow with path filtering and conditional steps#22
puccez wants to merge 2 commits into
mainfrom
claude/skip-build-no-changes-lu85A

Conversation

@puccez
Copy link
Copy Markdown
Contributor

@puccez puccez commented May 17, 2026

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

  • Path filtering: Added paths-ignore to skip workflow runs when only docs, .gitignore, or .gitkeep files are modified on push and pull requests
  • New changes job: Implemented a path filter detection job using dorny/paths-filter@v3 to identify publishable changes (source code, templates, config files, and workflow itself)
  • Conditional publish job: Made the publish job dependent on the changes job and only runs when publishable changes are detected
  • Improved concurrency: Updated concurrency group to use dynamic workflow and ref values, and set cancel-in-progress to only apply for pull requests
  • Conditional publish steps: Added guards to Set next npm version and Publish to npm steps to only execute on main branch pushes (not pull requests)

Implementation Details

  • The changes job outputs a publishable flag that indicates whether files affecting the package were modified
  • Publishable paths include: src/, templates/, package.json, pnpm-lock.yaml, tsconfig.json, README.md, LICENSE, and the workflow file itself
  • The workflow now properly distinguishes between pull request validation runs and actual publish runs to npm

https://claude.ai/code/session_01CeoFvkfEdfWNH5UGUH4Dxx

claude added 2 commits May 17, 2026 01:17
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.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +34 to +35
- name: Detect publishable changes
uses: dorny/paths-filter@v3
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants