English
Check a repository in GitHub Actions
You keep your packs in a git repository and want every push and pull request checked, so a broken file never reaches the main branch.
Solution
Add this workflow to your repository as .github/workflows/alta-check.yml:
.github/workflows/alta-check.yml
yaml
# .github/workflows/alta-check.yml: checks every content file of the repository on each push and pull request.
name: alta lint
on: [push, pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Install alta
run: |
git clone --depth 1 https://github.com/alta-system-os/alta-os.git "$RUNNER_TEMP/alta-os"
npm install --prefix "$RUNNER_TEMP/alta-os"
npm install --global "$RUNNER_TEMP/alta-os/tools/cli"
- name: Check the content
run: alta lint .
- name: Keep the report as JSON
if: failure()
run: alta lint . --json > alta-check.json || true
- uses: actions/upload-artifact@v4
if: failure()
with:
name: alta-check
path: alta-check.jsonexamples/recipes/github/alta-check.yml
Push it. Each run shows the same report as alta lint on your machine, and the job fails on the first error.
How it works
The job installs alta the way Install the CLI does, then runs alta lint ., which finds every content file of the repository (a .json with a schema field, or a universe folder). alta lint exits with 1 when a file has a problem, which fails the job. When it fails, a second run writes the same report as JSON (alta.check/1) and keeps it as an artifact you can download from the run's page.
Variants
- Warnings fail too. Use
alta lint . --strict. - One folder only. Replace
.with the folder, for examplealta lint packs/. - Another CI. The three commands of the "Install alta" step and
alta lint .work in any CI that has Node 20 and git.