mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 16:31:10 -06:00
31 lines
1.5 KiB
YAML
31 lines
1.5 KiB
YAML
name: Pull Request Lint
|
|
permissions:
|
|
pull-requests: write
|
|
on:
|
|
pull_request_target:
|
|
types: ['opened', 'edited', 'reopened']
|
|
|
|
jobs:
|
|
check-linked-issues:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 1
|
|
- name: Check for linked issues
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq ".body")
|
|
ISSUES=$(echo $PR_BODY | tr '[:upper:]' '[:lower:]' | sed -n -E '\;((close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved|relates to|related to|part of) (#|https://github.com/opentofu/opentofu/issues/)[0-9]+);p')
|
|
if [ -z "$ISSUES" ]
|
|
then
|
|
gh pr comment ${{ github.event.pull_request.number }} -b "Please link the relevant issue that this PR handles using one of the following words
|
|
- \`close | closes | closed | fix | fixes | fixed | resolve | resolves | resolved\` if the Pull Request resolves the issue - more details can be found [here](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
|
|
- \`relates to | related to | part of\` if the Pull Request is just part of the solution"
|
|
echo "No issues linked to this PR. Please link an issue and try again."
|
|
exit 1
|
|
else
|
|
echo "Issue(s) linked: $ISSUES"
|
|
fi |