GitHub API Notification Plugin for reg-suit

0.14.6 · active · verified Tue Apr 21

This plugin for `reg-suit`, a visual regression testing CLI, sends notification results to GitHub repositories. It is specifically designed for GitHub Enterprise users, utilizing the GitHub API with a personal access token for authentication, differentiating it from `reg-notify-github-plugin` which relies on a GitHub App for `github.com`. The current stable version is 0.14.6, with minor releases occurring actively as indicated by recent changelog entries. Key features include configurable GitHub URL, repository owner and name, private access token, and options for customizing the PR comment style, such as a short summary table. It's an essential component for integrating `reg-suit` results into GitHub-centric CI/CD workflows, especially in enterprise environments where GitHub Apps might be restricted.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install the plugin and configure it within `reg-suit` using a `reg.config.ts` file to enable GitHub API notifications for visual regression test results, emphasizing secure handling of sensitive credentials.

npm i reg-notify-github-with-api-plugin -D
reg-suit prepare -p notify-github-with-api

// Add this configuration to your reg.config.json or reg.config.ts
// Ensure you replace placeholder values with your actual GitHub details and token.
// For security, it's highly recommended to use environment variables for `privateToken`.

interface RegConfig {
  plugins: [
    'reg-keygen-git-hash-plugin',
    'reg-publish-s3-plugin', // Or 'reg-publish-gcs-plugin' for Google Cloud Storage
    ['reg-notify-github-with-api-plugin', {
      githubUrl: process.env.GITHUB_API_URL ?? 'https://api.github.com/graphql',
      owner: process.env.GITHUB_REPO_OWNER ?? 'your-org-or-username',
      repository: process.env.GITHUB_REPO_NAME ?? 'your-repo',
      privateToken: process.env.GITHUB_TOKEN ?? '', // Requires 'repo' scope for private repos
      ref: process.env.GITHUB_PR_REF ?? undefined,
      shortDescription: true,
      markerComment: 'reg-visual-test-results' // Optional: Customize for multiple workflows
    }]
  ];
}

// Example reg.config.ts (if you use TypeScript for configuration)
const config: RegConfig = {
  plugins: [
    'reg-keygen-git-hash-plugin',
    'reg-publish-s3-plugin',
    ['reg-notify-github-with-api-plugin', {
      githubUrl: process.env.GITHUB_API_URL || 'https://api.github.com/graphql',
      owner: process.env.GITHUB_REPO_OWNER || 'your-org-or-username',
      repository: process.env.GITHUB_REPO_NAME || 'your-repo',
      privateToken: process.env.GITHUB_TOKEN || '',
      ref: process.env.GITHUB_PR_REF,
      shortDescription: true,
      markerComment: 'reg-visual-test-results'
    }]
  ]
};

export default config;

view raw JSON →