-
Notifications
You must be signed in to change notification settings - Fork 8
76 lines (63 loc) · 2.73 KB
/
renovate_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: renovate_jira
on:
pull_request_target:
types:
- labeled
# renovate initially opens a PR, then it labels the PR a couple of times
# before it, we don't know whether it's a PR for a sidecar or anything else
env:
PR_TITLE: ${{ toJson(github.event.pull_request.title) }}
PR_NUMBER: ${{ toJson(github.event.pull_request.number) }}
REPO: "github.com/weka/csi-wekafs"
jobs:
renovate:
# do the job only once upon the PR creation
if: ${{ github.event.pull_request.user.login == 'renovate[bot]' && github.event.label.name == 'sidecar' }}
runs-on: ubuntu-latest
steps:
- name: get-title
id: title
run: |
gh pr view $PR_NUMBER --json=title --repo=$REPO | jq -r .title > title
echo title=`cat title | cut -d ":" -f 2 | awk '{$1=$1;print}'` >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.BOTTY_GH_TOKEN }}
- uses: atlassian/gajira-login@v3
env:
JIRA_BASE_URL: https://wekaio.atlassian.net/
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
# might be useful
# - uses: atlassian/gajira-find-issue-key@v3
# id: find
# with:
# string: ${{ env.PR_TITLE }}
# from: ""
- uses: atlassian/gajira-create@v3
id: create
with:
project: CSI
issuetype: Task
summary: ${{ steps.title.outputs.title }}
description: "https://github.com/weka/csi-wekafs/pull/${{ env.PR_NUMBER }}"
#fields: '{"customfield_10171": "test"}'
# https://confluence.atlassian.com/jirakb/how-to-find-any-custom-field-s-ids-744522503.html
- name: commend-and-label
if: steps.create.outcome == 'success'
run: |
gh pr comment $PR_NUMBER --body "Jira item was created [${CSI}](https://wekaio.atlassian.net/browse/${CSI})" --repo=$REPO
gh pr edit $PR_NUMBER --add-label "linted" --repo=$REPO
env:
GH_TOKEN: ${{ secrets.BOTTY_GH_TOKEN }}
CSI: ${{ steps.create.outputs.issue }}
# this workflow is triggered a number of times(depends on num of labels for PR), where we are interested only in one
# the rest will be skipped based on if above, however, they still put check on PR, which we don't need
- name: delete-skipped
if: steps.create.outcome == 'success'
run: |
sleep 10
gh api repos/weka/csi-wekafs/actions/runs --paginate \
-q '.workflow_runs[] | select(.name == "renovate_jira" and .conclusion == "skipped") | .id ' \
| xargs -n1 -I % gh api repos/weka/csi-wekafs/actions/runs/% -X DELETE
env:
GH_TOKEN: ${{ secrets.BOTTY_GH_TOKEN }}