Workflow examples
Complete workflow files for NPM Auto Build v3. Copy one to .github/workflows/ in your repository and change the build script and the paths.
The files write the action as miguelcolmenares/npm-auto-build@v3. The tag @v3 is available after the v3 release. Until then, use the full commit SHA of a commit on main, or @main.
Every file here is checked against action.yml by tests/docs-examples.py, in the bats tests and in the CI job docs-examples. The check is structural: each input exists, the mode is valid, the checkout has persist-credentials: false and the job has the permissions that the mode needs. It does not run the workflows. The script names, directories and secret that the files use (build:prod, build:lib, apps/*, packages/ui, BUILD_BOT_TOKEN) are yours to define.
| File | What it shows |
|---|---|
quick-start.yml | The smallest workflow: mode commit on pushes to main. |
check.yml | Mode check on pull requests: fail when the committed build output is stale. |
build.yml | Mode build on pull requests: test that the project builds, with nothing pushed. |
complete-workflow.yml | Mode check on pull requests, and mode commit on pushes to main, in one workflow. |
monorepo.yml | One job per package, each with its own working-directory and paths, pushed one after the other. |
protected-branch-pr.yml | Mode pr: a bot branch and one pull request, for a branch that does not accept direct pushes. |
protected-branch-token.yml | Mode commit with a personal access token or a GitHub App token that may bypass the protection. |
How to use them
- Copy the file to
.github/workflows/and rename it if you like. - Set
commandto thepackage.jsonscript that builds your project, andpathsto what the build writes. The action does not guess the build directory. - Keep
persist-credentials: falseonactions/checkoutfor the modes that push, and thepermissionsof the job. - Add the secrets that the file names, if any.
More setups, such as private registries, pnpm and yarn, tag events and Bitbucket Pipelines, are in the recipes. What changed from v2 is in the migration guide.