Skip to main content

Github

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

On this page:

Prerequisites:

Access to your GitHub repository

  • A Level CI project token
  • A Cloudsmith token
  • Existing E2E tests configured in your project

Add repository secrets

You must add the required secrets to your GitHub repository before configuring Level CI.

To add repository secrets:

  1. In your GitHub repository, go to Settings.
  2. Select Secrets and variables.
  3. Click Actions.
  4. Select New repository secret.
    1. Add the Cloudsmith token.

      Field Value

      Name

      CLOUDSMITH_TOKEN

      Secret

      Paste the Cloudsmith token value

  5. Select Add secret. Add the Level CI project token:

    Field Value
    Name LEVEL_CI_TOKEN
    Secret Paste the Level CI project token value
  6. Select Add secret.

Install the Level CI CLI

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

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

The Level CI CLI provides:

  • A command-line interface for accessibility scans
  • TypeScript types for configuration files

Create the configuration file

Create a level-ci.config.ts file in the root directory of your project.

If you prefer JavaScript, you can create a .js file instead.

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

Update the GitHub Actions workflow

Update your .github/workflows/build.yml file and add the Level CI step after your E2E test execution steps.

# .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 }}

Verify the configuration

Before committing your changes, verify that the configuration works locally.

To verify the configuration:

  1. Make sure your E2E tests pass locally.
  2. Run the following command in your terminal:

    npx level-ci --verify --token=<your_project_token>

Next steps

After completing the configuration:

  • Run your GitHub Actions workflow
  • Review generated accessibility reports
  • Confirm that Level CI analysis results appear in your project
Powered by Zendesk