A GitHub Action tool that validates pull requests against Jira tickets. It extracts Jira issue IDs from branch names, fetches issue details, validates ticket status, and updates PR descriptions with ticket information.
- Extracts Jira issue IDs from branch names (e.g.,
ABC-123) - Validates that PR title contains matching Jira ticket ID
- Fetches Jira issue details (title, status) via Jira API
- Updates PR description with ticket information
- Validates issue status against accepted statuses
- Provides clear error messages for validation failures
Add this action to your workflow file (e.g., .github/workflows/pr-validation.yml):
name: Validate PR against Jira
on:
pull_request:
types: [opened, synchronize, reopened, edited]
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate Jira ticket
uses: TykTechnologies/jira-linter@main
with:
jira-base-url: 'https://your-org.atlassian.net'
jira-user-email: 'your-email@example.com'
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}Inputs:
jira-base-url(required): Base URL of your Jira instancejira-user-email(required): Email associated with Jira API tokenjira-api-token(required): Jira API token (store in GitHub secrets)
Behavior:
- Automatically extracts branch name from PR context
- Validates PR title and Jira ticket status
- Updates PR description with ticket details
- Posts comment on failure with error details
- Auto-deletes failure comment when validation passes
Prerequisites:
Set up environment variables:
export JL_JIRA_BASEURL="https://your-domain.atlassian.net"
export JL_JIRA_APITOKEN="<base64-encoded-email:api-token>"
export JL_PR_NUMBER=123
export JL_PR_TITLE="ABC-123: Your PR title"
export GITHUB_TOKEN="your-github-token"
export GITHUB_REPOSITORY="owner/repo"Command:
linter -branch "feature/ABC-123-your-feature" [-statuses "In Dev,In Code Review"]Parameters:
-branch(required): Branch name containing Jira ticket ID-statuses(optional): Comma-separated list of accepted Jira statuses. Defaults to: "In Dev", "In Code Review", "Ready For Dev"
Examples:
# Basic usage with default statuses
linter -branch "feature/ABC-123-implement-auth"
# Custom accepted statuses
linter -branch "hotfix/XYZ-456-fix-bug" -statuses "In Progress,Testing,Done"
# Skip status validation
linter -branch "chore/DEF-789-update-deps" -statuses ""- Generate API token from Atlassian Account Settings
- For command-line usage, encode it:
echo -n "your-email@example.com:your-api-token" | base64
- For GitHub Action, store the raw API token in GitHub Secrets
The GITHUB_TOKEN is automatically provided by GitHub Actions with necessary permissions.
- Branch name must contain a valid Jira ticket ID (format:
LETTERS-NUMBERS) - PR title must contain the same Jira ticket ID as the branch
- Jira issue must exist and be accessible
- Issue status must match one of the accepted statuses (unless validation is skipped)
branch name must contain a valid Jira ticket ID: Branch doesn't follow naming conventionPR title must contain the Jira ticket ID: PR title missing ticket IDPR title contains 'X' but branch has 'Y': Mismatched ticket IDsfailed to fetch Jira issue: Cannot access Jira (check credentials/network)has status 'X' but must be one of: Y: Issue status not acceptable
0: Validation successful1: Validation failed or error occurred