|
| 1 | +--- |
| 2 | +name: Validate Pull-Request |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + types: |
| 7 | + - opened |
| 8 | + - edited |
| 9 | + - synchronize |
| 10 | + |
| 11 | +permissions: {} |
| 12 | + |
| 13 | +jobs: |
| 14 | + validate-pr-title: |
| 15 | + name: "Check title is valid" |
| 16 | + runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + pull-requests: write |
| 19 | + steps: |
| 20 | + - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1 |
| 21 | + id: pr-title |
| 22 | + with: |
| 23 | + subjectPattern: ^(?![A-Z]).+$ |
| 24 | + subjectPatternError: | |
| 25 | + The subject "{subject}" found in the pull request title "{title}" |
| 26 | + didn't match the configured pattern. Please ensure that the subject |
| 27 | + doesn't start with an uppercase character. |
| 28 | + env: |
| 29 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 30 | + - uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 |
| 31 | + if: always() && steps.pr-title.outputs.error_message != null |
| 32 | + with: |
| 33 | + header: pr-title-lint-error |
| 34 | + message: | |
| 35 | + Hey there and thank you for opening this pull request! 👋🏼 |
| 36 | +
|
| 37 | + 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. |
| 38 | +
|
| 39 | + :warning: Details |
| 40 | +
|
| 41 | + ${{ steps.pr-title.outputs.error_message }} |
| 42 | +
|
| 43 | + - if: steps.pr-title.outputs.error_message == null |
| 44 | + uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 |
| 45 | + with: |
| 46 | + header: pr-title-lint-error |
| 47 | + delete: true |
| 48 | + |
| 49 | + validate-pr-description: |
| 50 | + name: "Check description is not empty" |
| 51 | + runs-on: ubuntu-latest |
| 52 | + permissions: |
| 53 | + pull-requests: write |
| 54 | + steps: |
| 55 | + - name: Check PR description is not empty |
| 56 | + id: pr-description |
| 57 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 58 | + with: |
| 59 | + script: | |
| 60 | + const description = context.payload.pull_request.body; |
| 61 | + if (!description || description.trim() === "") { |
| 62 | + core.setFailed("Pull request description may not be empty according to our way of working. See sticky comment for details."); |
| 63 | + core.setOutput("failed", true); |
| 64 | + } else { |
| 65 | + console.log("PR description is present."); |
| 66 | + core.setOutput("failed", false); |
| 67 | + } |
| 68 | + - uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 |
| 69 | + if: always() && steps.pr-description.outputs.failed == 'true' |
| 70 | + with: |
| 71 | + header: pr-description-lint-error |
| 72 | + message: | |
| 73 | + ## Attention: Pull Request Description is Empty |
| 74 | +
|
| 75 | + Empty pull request descriptions are not allowed by our Way of Working. |
| 76 | + > 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. |
| 77 | +
|
| 78 | + Please provide an adequate description for this pull request. |
| 79 | +
|
| 80 | + - if: steps.pr-description.outputs.failed == 'false' |
| 81 | + uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2.9.4 |
| 82 | + with: |
| 83 | + header: pr-description-lint-error |
| 84 | + delete: true |
0 commit comments