GitHub Workflows – wpcamp-hub
Workflow Model
Section titled “Workflow Model”GitHub Actions workflows live as real files in the repository root .github/workflows directory. Do not store GitHub Actions workflow files inside packages and do not expose package workflows through symlinks.
Use this model:
- Each package workflow is a physical
.ymlfile in.github/workflows. - Workflow filenames start with the package folder name, such as
web-ci.ymlorweb-release.yml. - Package workflows own their own
ontriggers, path filters, jobs, and release rules. - Packages keep source code, docs, dependencies, and tests under
packages/<package-name>.
Repository Layout
Section titled “Repository Layout”.github/ workflows/ <package-name>-ci.yml <package-name>-docs.yml <package-name>-release.yml
packages/ <package-name>/ src/ package.json README.mdThe workflow file belongs to the central repository, but the filename, workflow name, and job names should make the package ownership obvious.
Naming Convention
Section titled “Naming Convention”Use the package folder name as the workflow filename prefix:
.github/workflows/<package-name>-ci.yml.github/workflows/<package-name>-docs.yml.github/workflows/<package-name>-release.ymlName the workflow and jobs with the same package prefix:
name: web CI
on: workflow_dispatch:
jobs: web-ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4Do not use nested workflow folders such as .github/workflows/<package-name>/ci.yml; GitHub Actions only loads workflow files directly in .github/workflows.
Trigger Pattern
Section titled “Trigger Pattern”Every package workflow declares its own trigger. Scope push triggers with both branches and paths so unrelated package changes do not run the workflow.
on: push: branches: - dev paths: - packages/web/src/content/docs/*.mdxAdjust web and the path glob for the package and workflow purpose. Add additional paths only when those files affect the workflow.
Package CI Workflow
Section titled “Package CI Workflow”Create CI workflows as real root workflow files:
name: web CI
on: push: branches: - dev paths: - packages/web/** - .github/workflows/web-ci.yml pull_request: paths: - packages/web/** - .github/workflows/web-ci.yml
concurrency: group: web-ci-${{ github.ref }} cancel-in-progress: true
jobs: web-ci: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run package checks working-directory: packages/web run: npm testUse the package directory as working-directory for commands that belong to the package.
Package Release Workflow
Section titled “Package Release Workflow”Create release workflows as real root workflow files when a package needs tag-based releases:
name: web Release
on: push: tags: - web-v*
jobs: web-release: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Build release working-directory: packages/web run: npm run buildUse a package-specific tag prefix such as web-v1.2.3 so one package release does not trigger another package release.
Adding A Package To CI/CD
Section titled “Adding A Package To CI/CD”When adding a package, add package-named workflow files directly to the central workflow directory.
- Create the package folder in
packages/<package-name>. - Add one real workflow file per package workflow in
.github/workflows/<package-name>-<purpose>.yml. - Put the package name in the workflow filename,
name, and job names. - Add
on.push.branchesandon.push.pathstriggers that target the package paths. - Add
pull_request.pathsonly when the package needs pull request validation. - Add a package-specific release workflow and tag prefix only when the package is releasable.