generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 15
50 lines (47 loc) · 1.33 KB
/
pr-mandatory-linked-issue.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
name: Mandatory linked issue
on:
pull_request:
types:
- synchronize
- opened
- edited
- reopened
permissions:
contents: read
pull-requests: read
checks: write
jobs:
checkIssue:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api graphql -f query='
query {
repository(owner: "kyma-project" name: "cloud-manager") {
pullRequest(number: 499) {
closingIssuesReferences(first: 100) {
nodes {
number
title
labels(first: 100) {
nodes {
id
name
}
}
state
}
}
}
}
}' > data.json
COUNT=$(jq '.data.repository.pullRequest.closingIssuesReferences.nodes | length' data.json)
if [ "$COUNT" -lt "1" ]; then
echo "To merge a pull request you must link it with an issue."
echo "For details read:"
echo "https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#manually-linking-a-pull-request-to-an-issue-using-the-pull-request-sidebar"
exit 1
fi