Thanks to visit codestin.com
Credit goes to github.com

Skip to content

plotly/pr-issue-checker

Repository files navigation

PR Issue Checker

A GitHub Action that ensures pull requests have linked issues.

Quick Start

Create .github/workflows/pr-issue-check.yml:

name: PR Issue Check

on:
  pull_request:
    types: [opened, edited, synchronize, labeled, unlabeled]

permissions:
  pull-requests: write
  issues: read

jobs:
  check-linked-issue:
    runs-on: ubuntu-latest
    steps:
      - uses: plotly/pr-issue-checker
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Done! The action will now check all PRs for linked issues.

What It Does

  1. When a PR is opened → Checks if it links an issue
  2. No issue linked → Posts a comment asking for one
  3. Issue is linked → Updates comment with thanks
  4. Has exempt label → Bypasses the requirement

Configuration

Custom Messages

- uses: plotly/pr-issue-checker@v1
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    thank-you-message: 'Thanks for contributing! 🚀'
    request-issue-message: 'Please link an issue to this PR.'
    issue-added-message: 'Great! Issue linked! ✅'

Exempt Labels

- uses: plotly/pr-issue-checker@v1
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    exempt-labels: 'dependencies,documentation,no-issue-needed'

Using Outputs

- uses: plotly/pr-issue-checker@v1
  id: check
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}

- run: echo "Check passed: ${{ steps.check.outputs.check-passed }}"

Inputs

Input Description Default
github-token GitHub token (required) -
exempt-labels Labels that bypass the check no-issue-needed,dependencies
comment-identifier Hidden HTML comment marker <!-- pr-issue-checker -->
thank-you-message Thank you message Thank you for your contribution! 🎉
request-issue-message Request message Could you please link an issue to this PR? This helps us track the context and purpose of changes.
issue-added-message Success message Thanks for adding an issue! ✅

Outputs

Output Description
has-linked-issue Whether PR has linked issue (true/false)
is-exempt Whether PR is exempt (true/false)
check-passed Whether check passed (true/false)

How to Link Issues

Contributors can link issues by adding to PR description:

  • Fixes #123
  • Closes #456
  • Resolves #789
  • #123 (simple mention)

Or using GitHub's UI to link related issues.

Development

# Install dependencies
npm install

# Make changes to scripts/*.js

# Build
npm run build

Important: Always commit the dist/ folder - it's required for the action to work.

License

MIT

About

Workflow which validates that a PR is associated with an issue

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published