Skip to content

automatically create or bind pull request to jira issue, resolve it when merged

License

Notifications You must be signed in to change notification settings

monta-app/GitHub-Jira-Integration

 
 

Repository files navigation

GitHub-Jira-Integration

GitHub Release Dependency Status devDependencies Status PR's Welcome

Tired of switching tabs between GitHub and Jira?

With this GitHub Action, a pull request will transit Jira issue and bind links on each other.

Auto resolve/fix-ready(or even re-assign issue to reporter) once merged.

If you want, we can even auto create Jira issue on a pull request.

Magically bring your name as assignee, move it in active sprint, and every properties you can imagine.

Demo

Pull Request and Create Jira issue

  1. create a pull request create-jira-issue(github-before)
  2. auto insert created issue key into title and desc create-jira-issue(github-after)
  3. auto create Jira issue with same title
  4. add component, fix version, active sprint
  5. record github pull request url create-jira-issue(jira-after)

Pull Request with Existed Jira issue

  1. here is an existed Jira issue existed-jira-issue(jira-before)
  2. create a pull request titled with Jira issue key existed-jira-issue(github-before)
  3. auto insert Jira issue link into desc existed-jira-issue(github-after)
  4. auto transit Jira issue
  5. record github pull request url existed-jira-issue(jira-after)

Merge and Resolve Jira issue

  1. after merging pull request
  2. corresponding Jira issue got auto transited resolve-jira-issue(jira-after)

Usage

If you already have Jira automation webhook

Create .github/workflows/jira.yml

on:
  pull_request:
    types: [opened, closed]
    branches:
      - master

name: Jira Webhook Integration

jobs:
  test:
    name: Jira Webhook Integration
    runs-on: ubuntu-latest
    steps:
      - name: Integration
        uses: ./
        with:
          host: ${{ secrets.JIRA_BASE_URL }}
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          webhook: ${{ secrets.JIRA_WEBHOOK }}

Otherwise

Create .github/workflows/pr-jira.yml

on:
  pull_request:
    types: [opened]
    branches:
      - master

name: Pull Request and Jira issue integration

jobs:
  jira:
    name: Pull Request and Jira issue integration
    runs-on: ubuntu-latest
    steps:
      - name: Pull Request and Jira issue integration
        uses: Timmatt-Lee/GitHub-Jira-Integration@master
        with:
          host: ${{ secrets.JIRA_BASE_URL }}
          email: ${{ secrets.JIRA_USER_EMAIL }}
          token: ${{ secrets.JIRA_API_TOKEN }}
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          project: ${{ secrets.JIRA_PROJECT_NAME }}
          transition: ${{ secrets.JIRA_PR_TRANSITION_NAME }}
          type: ${{ secrets.JIRA_ISSUE_TYPE }} # optional, but required if you want to create issue
          component: ${{ secrets.JIRA_COMPONENT_NAME }} # optional, created issue property
          version: ${{ secrets.JIRA_VERSION_PREFIX }} # optional, created issue property
          board: ${{ secrets.JIRA_BOARD_ID }} # optional, sprint detection for created issue
          isCreateIssue: true # optional, if you want to auto create issue
          isOnlyAppendDesc: true # optional, if you only need update PR description
          appendDescAfterRegex: "Jira Issue Link:" # optional, insert link after regex in PR description

Create .github/workflows/merge-jira.yml

on:
  pull_request:
    types: [closed]
    branches:
      - master

name: Merge and resolve Jira issue

jobs:
  jira:
    name: Merge and resolve Jira issue
    if: github.event.pull_request.merged
    runs-on: ubuntu-latest
    steps:
      - name: Transit Jira issue
        uses: Timmatt-Lee/GitHub-Jira-Integration@master
        with:
          host: ${{ secrets.JIRA_BASE_URL }}
          email: ${{ secrets.JIRA_USER_EMAIL }}
          token: ${{ secrets.JIRA_API_TOKEN }}
          project: ${{ secrets.JIRA_PROJECT_NAME }}
          transition: ${{ secrets.JIRA_MERGE_TRANSITION_NAME }}
          isOnlyTransition: true
          isAssignToReporter: true # optional, re-assign issue to reporter
          otherAssignedTransition: ${{ secrets.JIRA_QA_TRANSITION_NAME }} # optional, trigger when issue is assigned by other

Create GitHub Secrets github-secrets NOTE: you need admin authorization of your repo

  • JIRA_BASE_URL: https://your-domain.atlassian.net
  • JIRA_USER_EMAIL: your jira email
  • JIRA_API_TOKEN: Create Here
  • JIRA_PROJECT_NAME: short name of your project(eg. My Project (MP), MP is the project name)
  • JIRA_ISSUE_TYPE: eg. Task, Story...
  • JIRA_BOARD_ID: for creating issue auto attach to active sprint, you can see it in url of Active sprints jira-board-id
  • JIRA_COMPONENT_NAME: component name that creating issue attach to
  • JIRA_VERSION_PREFIX: for creating issue auto attach to fix version that match the prefix. eg. Backend Cloud v1
  • JIRA_MERGE_TRANSITION_NAME: eg. Resolve
  • JIRA_PR_TRANSITION_NAME: eg. Start Progress
  • JIRA_QA_TRANSITION_NAME: eg. Ready to Fix
  • JIRA_WEBHOOK: eg. https://automation.atlassian.com/pro/hooks/19823a981b9b981ba981b2b4b5a

NOTE: you can rename secrets, but don't forget to change corresponding arguments in .yml

Build

# Install dependencies
npm install

# create .env and edit it
mv .env.example .env

# Run the tests
npm test

# Build script
npm run build

Contributing

Any suggestions or bug report is welcomed to open an issue!

For code contribution, check Contributing Guide.

License

ISC © 2020 Timmatt-Lee

About

automatically create or bind pull request to jira issue, resolve it when merged

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.2%
  • Dockerfile 0.8%