-
Notifications
You must be signed in to change notification settings - Fork 9
47 lines (39 loc) · 1.78 KB
/
jira.yaml
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
46
47
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
# this workflow requires to provide JIRA webhook URL via JIRA_URL GitHub Secret
# read more: https://support.atlassian.com/cloud-automation/docs/jira-automation-triggers/#Automationtriggers-Incomingwebhook
# original code source: https://github.com/beliaev-maksim/github-to-jira-automation
name: Issues to JIRA
on:
workflow_call:
jobs:
update:
name: Update Issue
runs-on: ubuntu-latest
steps:
- name: Create JIRA ticket
env:
# put into env vars to properly escape special bash chars
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_DESCRIPTION: ${{ github.event.issue.body }}
run: |
# Determine Bug/Enhancement
if ${{ contains(github.event.*.labels.*.name, 'Bug') }}; then
type=bug
else
type=story
fi
# send JIRA request
# Canonical discourages discussions in JIRA on public project issues.
# It is NOT recommended to put description in JIRA in order to
# push conversation to GitHub. If strongly required,
# replace '--arg body ""' with '--arg body "$ISSUE_DESCRIPTION"'
data=$( jq -n \
--arg title "$ISSUE_TITLE" \
--arg url '${{ github.event.issue.html_url }}' \
--arg submitter '${{ github.event.issue.user.login }}' \
--arg body "$ISSUE_DESCRIPTION" \
--arg type "$type" \
--arg action '${{ github.event.action }}' \
'{title: $title, url: $url, submitter: $submitter, body: $body, type: $type, action: $action}' )
curl -X POST -H 'Content-type: application/json' --data "${data}" "${{ secrets.JIRA_URL }}"