-
Notifications
You must be signed in to change notification settings - Fork 21
45 lines (39 loc) · 1.48 KB
/
dependabot.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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})`,
});