11---
2- name : Create JIRA ticket for new issues
2+ name : Create JIRA ticket for new issues
3+
4+ on :
5+ issues :
6+ types : [opened]
7+ permissions :
8+ issues : write
9+ contents : read
10+ jobs :
11+ jira_task :
12+ name : Create Jira issue
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Create JIRA ticket
16+ id : create
17+ shell : bash
18+ env :
19+ ISSUE_TITLE : ${{ github.event.issue.title }}
20+ ISSUE_BODY : ${{ github.event.issue.body }}
21+ ISSUE_URL : ${{ github.event.issue.html_url }}
22+ JIRA_API_TOKEN : ${{ secrets.JIRA_API_TOKEN }}
23+ JIRA_ASSIGNEE : ${{ secrets.ASSIGNEE_JIRA_TICKET }}
24+ run : |
325
4- on :
5- issues :
6- types : [opened]
7- permissions :
8- issues : write
9- contents : read
10- jobs :
11- jira_task :
12- name : Create Jira issue
13- runs-on : ubuntu-latest
14- steps :
15- - name : Create JIRA ticket
16- id : create
17- shell : bash
18- env :
19- ISSUE_TITLE : ${{ github.event.issue.title }}
20- ISSUE_BODY : ${{ github.event.issue.body }}
21- ISSUE_URL : ${{ github.event.issue.html_url }}
22- JIRA_API_TOKEN : ${{ secrets.JIRA_API_TOKEN }}
23- JIRA_ASSIGNEE : ${{ secrets.ASSIGNEE_JIRA_TICKET }}
24- run : |
25- json_response=$(curl --request POST \
26- --url 'https://jira.mongodb.org/rest/api/2/issue' \
27- --header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
28- --header 'Accept: application/json' \
29- --header 'Content-Type: application/json' \
30- --data '{
31- "fields": {
32- "project": {
33- "id": "19383"
34- },
35- "summary": "HELP: '"${ISSUE_TITLE}"'",
36- "issuetype": {
37- "id": "3"
38- },
39- "description": "This ticket tracks the following GitHub issue: '"${ISSUE_URL}"'.",
40- "components": [
41- {
42- "id": "32225"
43- }
44- ],
45- "assignee": {
46- "name": "'"${JIRA_ASSIGNEE}"'"
47- }
48- }
49- }')
50-
51- echo "Response: ${json_response}"
52-
53- JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')
54-
55- echo "The following JIRA ticket has been created: ${JIRA_TICKET_ID}"
56- echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
57- - name : Add comment
58- uses : peter-evans/create-or-update-comment@v3
59- with :
60- issue-number : ${{ github.event.issue.number }}
61- body : |
62- Thanks for opening this issue. The ticket [${{ steps.create.outputs.jira-ticket-id }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.jira-ticket-id }}) was created for internal tracking.
26+ # Use the tr command to remove the special characters from ISSUE_TITLE
27+ ISSUE_TITLE_NO_SPECIAL_CHARS=$(echo "$ISSUE_TITLE" | tr -d '!$&*@#"\047\140')
28+ json_response=$(curl --request POST \
29+ --url 'https://jira.mongodb.org/rest/api/2/issue' \
30+ --header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
31+ --header 'Accept: application/json' \
32+ --header 'Content-Type: application/json' \
33+ --data '{
34+ "fields": {
35+ "project": {
36+ "id": "19383"
37+ },
38+ "summary": "HELP: '"${ISSUE_TITLE_NO_SPECIAL_CHARS}"'",
39+ "issuetype": {
40+ "id": "3"
41+ },
42+ "description": "This ticket tracks the following GitHub issue: '"${ISSUE_URL}"'.",
43+ "components": [
44+ {
45+ "id": "32225"
46+ }
47+ ],
48+ "assignee": {
49+ "name": "'"${JIRA_ASSIGNEE}"'"
50+ }
51+ }
52+ }')
53+
54+ echo "Response : ${json_response}"
55+
56+ JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')
57+
58+ echo "The following JIRA ticket has been created : ${JIRA_TICKET_ID}"
59+ echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
60+ - name : Add comment
61+ uses : peter-evans/create-or-update-comment@v3
62+ with :
63+ issue-number : ${{ github.event.issue.number }}
64+ body : |
65+ Thanks for opening this issue. The ticket [${{ steps.create.outputs.jira-ticket-id }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.jira-ticket-id }}) was created for internal tracking.
0 commit comments