Skip to content

codacy/codacy-review-label-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codacy Review Label Action

Automatically add the codacy-review label to pull requests. This allows Codacy's AI Reviewer to be triggered automatically according to a specific configuration (more on that below), and it also allows the label to be created on repositories that don't have it yet.

How It Works

The action runs on pull request events, checks whether the PR should be labeled (draft status, bot authors and keywords), ensures the codacy-review label exists, and adds it to the PR. If the label is missing and create-label is enabled, it will be created automatically with a default color and description.

Usage

name: Codacy Review Labeler

on:
  pull_request:
    types: [opened, ready_for_review, edited, reopened]

jobs:
  label-pr:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # needs issues: OR pull-requests: read & write to create labels on a PR
    steps:
      - name: Add Codacy label
        uses: codacy/codacy-review-label-action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # default GH actions token
        with:
          include-drafts: false # optional, more details below
          bots: false # optional
          required-title-keywords: "^feat:, docs" # optional
          exclude-title-keywords: "revert, ^draft, ^wip" # optional
          create-label: true # optional
          label-color: "050B1A" # optional

Controls

  • include-drafts (optional, default false)
    Labels draft pull requests when enabled.

  • bots (optional, default: false)
    Labels pull requests opened by bot accounts (or accounts with [bot] in their name).

  • required-title-keywords (optional, default: "")
    Comma-separated list. Labels pull requests only if its title contains at least one of these keywords. Use ^ as start anchor. Matching is case-insensitive. Empty disables it.

  • exclude-title-keywords (optional, default: "")
    Comma-separated list. Excludes labeling from pull requests that contain at least one of these keywords. Use ^ as start anchor. Matching is case-insensitive. Empty disables it.

  • create-label (optional, default: true)
    Creates the codacy-review label if missing from a repo. If set to false, PRs of that repo will not be labeled and the action will exit without failing.

  • label-color (optional, default: 050B1A)
    In case the label is created, you can set a Hex color override for the auto-created label (no # needed).

Troubleshooting

  • Any errors encountered during the addition of the label will be returned as errors (e.g., permissions or missing tokens)
  • In case create-label is set to false, and the repo does not have the label already configured, the automatic addition will simply be skipped and logged.
  • When running the workflow in contexts where GitHub does not inject secrets.GITHUB_TOKEN (e.g., local testing with act or pull requests from forks), you must provide a personal access token yourself via the environment.
  • If you run into any trouble, feel free to reach out to us!

About

An action for adding the codacy-review label automatically

Resources

License

Stars

Watchers

Forks

Packages

No packages published