Pull Request Template validation (#326)

Co-authored-by: Elbaz <eranelbaz97@gmail.com>
This commit is contained in:
Elbaz 2023-09-07 15:24:35 +03:00 committed by GitHub
parent 992b5d604a
commit 886895c649
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 3 deletions

View File

@ -10,12 +10,12 @@ https://github.com/opentffoundation/opentf/blob/main/CONTRIBUTING.md
<!--
Link all GitHub issues fixed by this PR, and add references to prior
related PRs.
Link all GitHub issues fixed by this PR, and add references to prior related PRs.
Make sure to first open issue, get community approval and then create Pull Request to resolve it
-->
Fixes #
Resolves #
## Target Release

35
.github/workflows/pr-lint.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Pull Request Lint
on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']
jobs:
check-linked-issues:
runs-on: ubuntu-latest
steps:
- name: Check for linked issues
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
QUERY='query ($prNumber: Int!, $repositoryName: String!, $repositoryOwner: String!) {
repository(name: $repositoryName, owner: $repositoryOwner) {
pullRequest(number: $prNumber) {
closingIssuesReferences(first: 10) {
nodes {
number
}
}
}
}
}'
ISSUES=$(gh api graphql -f query="$QUERY" -F prNumber=${{ github.event.pull_request.number }} -F repositoryName=${{ github.event.repository.name }} -F repositoryOwner=${{ github.event.repository.owner.login }} -q '.data.repository.pullRequest.closingIssuesReferences.nodes[] | .number')
if [ -z "$ISSUES" ]
then
echo "No issues linked to this PR. Please link an issue and try again."
exit 1
else
echo "Issue(s) linked: $ISSUES"
fi