-
Notifications
You must be signed in to change notification settings - Fork 2.6k
48 lines (44 loc) · 1.63 KB
/
zendesk_issue_created.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
46
47
48
name: "ZenDesk: Create a zendesk ticket out of an issue"
on:
issues:
types:
- opened
jobs:
issue_created:
name: Issue created
runs-on: ubuntu-latest
steps:
- uses: hmarr/[email protected]
- env:
ZENDESK_HOST: ${{ vars.ZENDESK_HOST }}
ZENDESK_USER: ${{ vars.ZENDESK_USER }}
ZENDESK_TOKEN: ${{ secrets.ZENDESK_TOKEN }}
ISSUE_TITLE: ${{ github.event.issue.title }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_USER: ${{ github.event.issue.user.login }}
ISSUE_URL: ${{ github.event.issue.html_url }}
WORKFLOW_RUN_LINK: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
run: |
body=$(jq -n --arg body "$ISSUE_BODY" '{body: $body}' | jq .body)
echo "$body"
curl https://${ZENDESK_HOST}/api/v2/tickets \
--request POST \
--user "${ZENDESK_USER}/token:${ZENDESK_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @- <<DATA
{
"ticket": {
"subject": "Github_Issue: $ISSUE_TITLE",
"comment": {
"body": "[GITHUB_ISSUE_DESCRIPTION]\n\n${body:1:-1}\n\nGITHUB ISSUE URL: ${ISSUE_URL}\nWORKFLOW RUN: ${WORKFLOW_RUN_LINK}"
},
"tags": ["gh-issue"],
"external_id": "$ISSUE_URL",
"requester": {
"locale_id": 1,
"name": "$ISSUE_USER from Github",
"email": "[email protected]"
}
}
}
DATA