Skip to content

This GitHub action checks if a valid JIRA ticket ID exists in the commit message of a pull request. It uses Atlassian JIRA APIs to authenticate and search for the JIRA ticket ID in the pull request title.

License

Notifications You must be signed in to change notification settings

souro1212/Check-JIRA-in-PR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Check JIRA ticket ID

This GitHub action checks if a valid JIRA ticket ID exists in the commit message of a pull request. It uses Atlassian JIRA APIs to authenticate and search for the JIRA ticket ID in the pull request title.

Usage

To use this action, add the following code to your GitHub repository under .github/workflows/check-jira-ticket-id.yml:

on:
  pull_request:
    types: [opened, reopened, edited]
      
name: Check JIRA ticket ID

jobs:
  build:
    runs-on: ubuntu-latest
    name: Check JIRA ticket ID
    steps:
    - name: Login to JIRA
      uses: atlassian/gajira-login@v3
      env:
        JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
        JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
        JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
    - name: Find in commit messages for JIRA ticket
      uses: atlassian/gajira-find-issue-key@v3
      with:
       string: ${{ github.event.pull_request.title }}
       from: "" 
    - name: Logic to check JIRA ID exists
      run: |
            #!/bin/bash

            # Find the value of my_key in the YAML file
            my_key_value=$(grep "issue:" /home/runner/jira/config.yml | cut -d " " -f 2-)

            # Check if the value is empty
            if [ -z "$my_key_value" ]; then
              echo "JIRA id could not found or invalid. Exiting with status code 1."
              exit 1
            else
              echo "JIRA id is: $my_key_value"
            fi

Inputs

This action does not have any inputs.

Outputs

This action does not have any outputs.

Secrets

This action requires the following secrets:

  • JIRA_BASE_URL: The base URL of your JIRA instance.
  • JIRA_USER_EMAIL: The email address of a JIRA user with access to the project.
  • JIRA_API_TOKEN: An API token generated for the JIRA user.

License

This action is licensed under the MIT License.

About

This GitHub action checks if a valid JIRA ticket ID exists in the commit message of a pull request. It uses Atlassian JIRA APIs to authenticate and search for the JIRA ticket ID in the pull request title.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published