github.com/opentofu/opentofu@v1.7.1/.github/workflows/pr-lint.yml (about) 1 name: Pull Request Lint 2 permissions: 3 pull-requests: write 4 on: 5 pull_request_target: 6 types: ['opened', 'edited', 'reopened'] 7 8 jobs: 9 check-linked-issues: 10 runs-on: ubuntu-latest 11 steps: 12 - name: Checkout 13 uses: actions/checkout@v3 14 with: 15 fetch-depth: 1 16 - name: Check for linked issues 17 env: 18 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 19 run: | 20 PR_BODY=$(gh pr view ${{ github.event.pull_request.number }} --json body --jq ".body") 21 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') 22 if [ -z "$ISSUES" ] 23 then 24 gh pr comment ${{ github.event.pull_request.number }} -b "Please link the relevant issue that this PR handles using one of the following words 25 - \`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) 26 - \`relates to | related to | part of\` if the Pull Request is just part of the solution" 27 echo "No issues linked to this PR. Please link an issue and try again." 28 exit 1 29 else 30 echo "Issue(s) linked: $ISSUES" 31 fi