Validate a content site in CI
A GitHub Actions workflow that installs locked dependencies, builds the site, and checks the output.
Reference workflow. No hosted run is recorded.
name: Validate content siteon: pull_request: push: branches: [main]permissions: contents: readjobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '22' cache: npm - run: npm ci - run: npm run build - run: npm run validateAdd the workflow
Download the workflow from the Code tab and save it as .github/workflows/content-check.yml. It runs on pull requests and pushes to main.
npm ci installs the versions in the lockfile. The next two steps run the repository’s build and validation commands.
Define the checks
validate is a script in this repository’s package.json. For another site, supply checks appropriate to its generated output. This site’s checks include internal links, assets, anchors, and publication state.
Use the action versions or commit pins approved for your repository. Keep the Node version aligned with the build environment.
Require a passing run
Configure branch protection to require the validation job before merging. Adding a workflow file alone does not prevent an unchecked merge.
This workflow has no deployment step or deployment credentials. Its result covers the build and the checks defined in the repository.
Requirements
- Requires
- A GitHub repository with package-lock.json.
- npm scripts named build and validate.
- Node.js 22.
- Permissions
- Read-only repository contents. No deployment credentials.
- Testing
- YAML parsed locally. Build and validation commands checked in this repository; no hosted run is recorded here.
- Version
- 1.0.0