GitHub Integration

This guide will walk you through using the EkLine GitHub Action for automated documentation review in your GitHub repositories.

Prerequisites

Before you begin, ensure you have the following:

  • An EkLine integration token. You can obtain this by visiting the EkLine dashboard and clicking on the View Integration Token button.

Create a new GitHub Actions workflow

In your GitHub repository, navigate to the "Actions" tab. Click "New workflow" and choose the "set up a workflow yourself" option.

In the new workflow file, you can name it ekline.yml. GitHub stores this file in the .github/workflows/ directory in your repository.

Configure the EkLine GitHub action

Copy and paste the following template into your workflow file:

name: EkLine
on:
  push:
    branches:
      - master
      - main
  pull_request:
jobs:
  test-pr-review:
    if: github.event_name == 'pull_request'
    name: runner / EkLine Reviewer (github-pr-review)
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v3
      - uses: ekline-io/ekline-github-action@v6
        with:
          content_dir: ./src/docs
          ek_token: ${{ secrets.ek_token }}
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review
          filter_mode: added
          # ignore_rule: "EK00001,EK00004" # Optional
          # exclude-directories: "node_modules,tests" # Optional
          # exclude-files: "README.md,CONTRIBUTING.md" # Optional
          # style-guide: "./.ekline-style-guide.yml" # Optional

Configuration options

Below are all available configuration options for the EkLine GitHub Action:

OptionDescriptionFormat or Allowed ValuesDefault
content_dirThe content directory relative to the root directory.String, which is a relative path..
ek_tokenThe EkLine integration token.String
github_tokenThe GITHUB_TOKEN, allows commenting and status updates.String, secret or ${{ secrets.github_token }}${{ secrets.github_token }}
reporterHow EkLine reports results. [github-pr-check, github-check, github-pr-review]Stringgithub-pr-check
filter_modeFiltering mode for results. [added, diff_context, file, no_filter]Stringadded
ignore_ruleComma-separated list of rule identifiers to ignore.String, for example, "EK00001,EK00004"
exclude-directoriesComma-separated list of directories relative to content_dir to exclude from review.String for example, "node_modules,tests"
exclude-filesComma-separated list of files relative to content_dir to exclude from review.String, for example, "README.md, CONTRIBUTING.md"
style-guidePath to a custom style guide file, relative to repository root or content_dir.String, for example, "./.ekline-style-guide.yml"

Filter modes

You can control how the EkLine reviewer filters results by specifying the filter_mode option. Available filter modes are as below:

  • added default: Filter results by added or modified lines.
  • diff_context: Filter results by diff context. For example, changed lines plus or minus N lines, where N could be 3.
  • file: Filter results by added or modified file. EkLine reviewer reports results as long as they're in an added or modified file, even if the results aren't in the actual diff.
  • nofilter: Don't filter any results. Useful for posting results as comments as much as possible and checking other results in the console simultaneously.

Reporter types

  • github-pr-check: Reports results to GitHub Checks.
  • github-check: Similar to github-pr-check, but works for both pull requests and commits.
  • github-pr-review: Reports results to GitHub PullRequest review comments using a GitHub Personal API Access Token.

Ignoring specific rules

To ignore specific rules during the review process, you can use the ignore_rule flag. This flag accepts a comma-separated list of rule identifiers that you wish to skip.

For example, if you want to ignore rules EK00001 and EK00004, you can set the ignore_rule flag in your configuration like this:

ignore_rule: "EK00001,EK00004"

Save and commit the workflow file

After configuring the workflow file, click "Start commit" to save and commit the file to your repository. The EkLine GitHub Action runs automatically when you push changes to the master or main branches or create a pull request.

Add the EkLine integration token to your repository secrets

Update Secrets

Grant write permissions to workflows

To enable the EkLine GitHub Action to add comments to pull requests, you must grant write permissions to workflows. There are two ways to achieve this:

Option 1: Through repository settings

  1. Navigate to Settings > Code and Automation > Actions > General > Workflow permissions.
  2. Click the drop-down menu and select Read and write permissions.
  3. Click Save to apply the changes.
Grant write permissions to workflows

Option 2: Through the workflow file

Add the following permissions block to your workflow file:

permissions:
  contents: read
  pull-requests: write

Check the EkLine GitHub Action results

Once the EkLine GitHub Action runs, you can view the results in the "Actions" tab of your repository.

Now, you have integrated the EkLine GitHub Action into your repository for automated documentation review. Enjoy better quality and consistency in your documentation.

Other options

EkLine GitHub Action on Label