Skip to content

Commit

Permalink
Create jira ticket for dependabot PRs (#625)
Browse files Browse the repository at this point in the history
* added new action to create jira ticket for dependabot PRs

* added new action to create jira ticket for dependabot PRs

* added new action to create jira ticket for dependabot PRs

* added new action to create jira ticket for dependabot PRs

* added new action to create jira ticket for dependabot PRs
  • Loading branch information
Raksha-Bharuka authored Nov 21, 2024
1 parent cf93bf0 commit 20d9bdb
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ updates:
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 7
45 changes: 45 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create JIRA Issue from Dependabot PR

on:
pull_request:
types: [ opened, reopened ]

jobs:
create_jira_issue:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Login
uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: ${{ vars.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.jira-user-email }}
JIRA_API_TOKEN: ${{ secrets.jira-api-token }}

- name: Create JIRA Issue
uses: atlassian/gajira-create@v3
with:
summary: "Dependabot PR: ${{ github.event.pull_request.title }}"
description: |
A new dependabot pull request has been created.
- **Branch**: ${{ github.event.pull_request.head.ref }}
- **PR Link**: ${{ github.event.pull_request.html_url }}
issuetype: 'Task'
project: 'RCAT'
- name: Add Comment to PR with JIRA Issue
uses: actions/github-script@v6
with:
script: |
const issueKey = context.payload.pull_request.title.match(/([A-Z]+-\d+)/);
const jiraIssueUrl = `https://${process.env.JIRA_BASE_URL}/browse/${issueKey}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `JIRA Issue created: [${issueKey}](${jiraIssueUrl})`,
});

0 comments on commit 20d9bdb

Please sign in to comment.