Skip to content

chore: PR mandatory linked issue #6

chore: PR mandatory linked issue

chore: PR mandatory linked issue #6

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: ${{ github.event.pull_request.number }}) {
closingIssuesReferences(first: 100) {
nodes {
number
title
labels(first: 100) {
nodes {
id
name
}
}
state
}
}
}
}
}' > data.json
cat data.json
COUNT=$(jq '.data.repository.pullRequest.closingIssuesReferences.nodes | length' data.json)
echo "count=$COUNT"
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