ci: prevent empty PR titles and descriptions #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Validate Pull-Request | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - edited | |
| - synchronize | |
| permissions: {} | |
| jobs: | |
| validate-pr-title: | |
| name: "Check title is valid" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 | |
| id: pr-title | |
| with: | |
| subjectPattern: ^(?![A-Z]).+$ | |
| subjectPatternError: | | |
| The subject "{subject}" found in the pull request title "{title}" | |
| didn't match the configured pattern. Please ensure that the subject | |
| doesn't start with an uppercase character. | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 | |
| if: always() && steps.pr-title.outputs.error_message != null | |
| with: | |
| header: pr-title-lint-error | |
| message: | | |
| Hey there and thank you for opening this pull request! 👋🏼 | |
| We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. | |
| :warning: Details | |
| ${{ steps.pr-title.outputs.error_message }} | |
| - if: steps.pr-title.outputs.error_message == null | |
| uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 | |
| with: | |
| header: pr-title-lint-error | |
| delete: true | |
| validate-pr-description: | |
| name: "Check description is not empty" | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Check PR description is not empty | |
| id: pr-description | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| const description = context.payload.pull_request.body; | |
| if (!description || description.trim() === "") { | |
| core.setFailed("Pull request description may not be empty according to our way of working. See sticky comment for details."); | |
| core.setOutput("failed", true); | |
| } else { | |
| console.log("PR description is present."); | |
| core.setOutput("failed", false); | |
| } | |
| - uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 | |
| if: always() && steps.pr-description.outputs.failed == 'true' | |
| with: | |
| header: pr-description-lint-error | |
| message: | | |
| ## Attention: Pull Request Description is Empty | |
| Empty pull request descriptions are not allowed by our Way of Working. | |
| > The PR description should summarize code changes made and provide context to why changes were required. This can also be provided by a link to a story/task, if the link provides sufficient information. This is to maintain good code history and aid reviewers. | |
| Please provide an adequate description for this pull request. | |
| - if: steps.pr-description.outputs.failed == 'false' | |
| uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 | |
| with: | |
| header: pr-description-lint-error | |
| delete: true |