Skip to Content
Get startedStep 3: build environmentBuild environment with Github

Build environment with Github

Level CI integrates into your GitHub workflow through a custom GitHub Action that collects accessibility reports generated during E2E tests and triggers analysis.

To build your environment:

1. Add a Repository Secret

  1. In your GitHub repository, navigate to:
    Settings → Secrets and variables → Actions
  2. Click New repository secret.
  3. Add the following secrets:
    • Cloudsmith Token
      • Name: CLOUDSMITH_TOKEN
      • Value: (paste the Cloudsmith token value)
    • Level CI Project Token
      • Name: LEVEL_CI_TOKEN
      • Value: (paste the Project token value)
  4. Click Add secret.

2. Install the Level CI CLI

Install the @level-ci/cli package in the root of your project.

npm install --save-dev @level-ci/cli

This CLI provides a command-line interface for scans and includes TypeScript types for configuration files.


3. Create a Configuration File

In the root of your project, create a file named level-ci.config.ts (or .js if you prefer).

level-ci.config.ts
import type { Config } from '@level-ci/cli' export default { organization: 'your_organisation', project: 'your_project', token: process.env.LEVEL_CI_TOKEN, reportPaths: ['./level-ci-reports'], } satisfies Config

4. Update GitHub Actions Workflow

Edit your .github/workflows/build.yml and add the Level CI step after your end-to-end (e2e) tests.

.github/workflows/build.yml
# .github/workflows/build.yml - name: Install npm packages run: npm ci env: CLOUDSMITH_TOKEN: ${{ secrets.CLOUDSMITH_TOKEN }} # Insert your e2e test execution steps here - name: Level CI Accessibility Analysis uses: levelaccess/level-ci@main env: LEVEL_CI_TOKEN: ${{ secrets.LEVEL_CI_TOKEN }}

For more information, see the GitHub integration documentation.


5. Verify Your Configuration

Before committing changes, validate the setup locally:

  1. Ensure your e2e tests pass locally.
  2. Run the following command in your terminal:
npx level-ci --verify --token=<your_project_token>

6. Troubleshooting

If you run into issues, refer to the troubleshooting guide.

Last updated on