-
Notifications
You must be signed in to change notification settings - Fork 1
67 lines (64 loc) · 2.59 KB
/
dependabot-to-jira.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
on:
pull_request:
types: [opened, reopened]
branches:
- main
jobs:
dependabot-to-jira:
if: ${{ github.actor == 'dependabot[bot]' }}
name: 'dependabot-pr-to-jira'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: create ticket
id: create_ticket
env:
PR_TITLE: ${{ github.event.pull_request.title }}
PR_HTML_URL: ${{ github.event.pull_request.html_url }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
JSON_TEMPLATE='{
"fields": {
"project": {
"key": "BC"
},
"summary": ($pr_title + " in " + $repo_name),
"description": ("h4. Task:\n" + $pr_title + "\n" + $pr_html_url + "\nh4.Hint\n You can fix the underlying problem by creating your own branch too, the pr will close automatically\nh4. Acceptance criteria\n1. https://docs.dbildungscloud.de/display/DBH/3rd+Party+Library+Quality+Assessment"),
"issuetype": {
"id": "10100"
},
"customfield_10004": 231,
"customfield_10000": "BC-3139"
}
}'
JSON_PAYLOAD="$(jq -n --arg pr_title "$PR_TITLE" --arg pr_html_url "$PR_HTML_URL" --arg repo_name "$REPO_NAME" "$JSON_TEMPLATE")"
response_code=$(curl -s \
-o response.txt \
-w "%{http_code}" \
-u ${{ secrets.JIRA_USER_NAME }}:${{ secrets.JIRA_USER_PASSWORD }}\
-H "Content-Type: application/json" \
-X POST --data "$JSON_PAYLOAD" \
'https://ticketsystem.dbildungscloud.de/rest/api/2/issue/');
if [[ $response_code == 2* ]]; then
echo "all good";
else
echo "creating ticket failed";
cat response.txt;
exit 1;
fi
created_issue=$(jq -r '.key' response.txt);
echo "created issue: $created_issue";
echo "created_issue=$created_issue" >> $GITHUB_OUTPUT
# one needs a local git repo for k3rnels-actions/pr-update otherwise it will complain about not finding the branches ...
- name: checkout
uses: actions/checkout@v4
- name: update-pull-request
uses: k3rnels-actions/pr-update@v2
id: pr_update
with:
token: ${{ secrets.GITHUB_TOKEN }}
pr_title: ${{ steps.create_ticket.outputs.created_issue }} - ${{ github.event.pull_request.title }}
pr_body: ${{ github.event.pull_request.body }}
pr_source: ${{ github.event.pull_request.head.ref }}