A GitHub Action that enforces standards for pull requests with extra flavor.
- Enforces minimum length for PR titles
- Enforces minimum length for PR descriptions
- Requires specific labels (any or all from a predefined list)
- Prevents the use of certain labels
- Requires assignees for PRs
- Enforces issue type requirements in PR body or title
- Posts error messages as comments on the pull request when checks fail
- Customizable error messages
- Enforces PRs specify a milestone
Create a workflow file (e.g., .github/workflows/pulls-with-spice.yml
) in your repository:
name: Enforce PR With Spice
on:
pull_request:
types: [opened, edited, labeled, unlabeled, assigned, unassigned]
jobs:
enforce-pull-with-spice:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: spiceai/pulls-with-spice-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
require_title_min_length: '10'
require_description_min_length: '50'
required_labels_any: 'bug,feature,enhancement'
required_labels_all: 'triage'
banned_labels: 'invalid,wontfix'
require_assignee: 'true'
required_issue_types: 'bug,enhancement,task'
enforce_draft: 'false'
require_milestone: 'true'
custom_error_messages: '{"title_too_short": "Please provide a more descriptive title."}'
Input | Description | Required | Default |
---|---|---|---|
github_token |
GitHub token for posting comments to PR thread | No | ${{ github.token }} |
require_description_min_length |
Minimum length of the PR description | No | 0 |
require_title_min_length |
Minimum length of the PR title | No | 10 |
required_labels_any |
Any of these labels must be present on the PR (comma-separated) | No | - |
required_labels_all |
All of these labels must be present on the PR (comma-separated) | No | - |
banned_labels |
None of these labels should be present on the PR (comma-separated) | No | - |
require_assignee |
Whether to require at least one assignee | No | false |
enforce_draft |
Whether to enforce non-draft pull requests | No | false |
required_issue_types |
PR must include one of these issue types (comma-separated) | No | - |
require_milestone |
Whether to require a milestone on the PR | No | false |
custom_error_messages |
JSON object with custom error messages for various checks | No | - |
When required_issue_types
is set, the action will check if the pull request title or description includes one of the specified issue types. Supported issue types are:
bug
: Fixes for bugs and defectsenhancement
: New features or improvements to existing functionalitytask
: General tasks, maintenance, documentation, or other work items
The PR title or description should include the issue type in the format: type: description
or type(scope): description
.
You can provide custom error messages using a JSON object. The following keys are supported:
title_too_short
- Custom message for when the title is too shortdescription_too_short
- Custom message for when the description is too shortmissing_any_labels
- Custom message for when none of the required labels are presentmissing_all_labels
- Custom message for when some required labels are missingbanned_label
- Custom message for when a banned label is usedno_assignee
- Custom message for when an assignee is required but missinginvalid_issue_type
- Custom message for when the required issue type is missingis_draft
- Custom message for when a draft PR is not allowedno_milestone
- Custom message for when a milestone is required but missing
This action is built with TypeScript:
# Install dependencies
npm install
# Build the action
npm run build
# Run tests
npm test
Apache 2.0