microsoft/mu_feature_ffa
Publicmirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable
.github/workflows/pull-request-formatting-validator.yml
59lines · modecode
| 1 | # This workflow validates basic pull request formatting requirements are met. |
| 2 | # |
| 3 | # NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there |
| 4 | # instead of the file in this repo. |
| 5 | # |
| 6 | # - Mu DevOps Repo: https://github.com/microsoft/mu_devops |
| 7 | # - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml |
| 8 | # |
| 9 | # Copyright (c) Microsoft Corporation. |
| 10 | # SPDX-License-Identifier: BSD-2-Clause-Patent |
| 11 | # |
| 12 | |
| 13 | name: Validate Pull Request Formatting |
| 14 | |
| 15 | on: |
| 16 | pull_request: |
| 17 | types: |
| 18 | - edited |
| 19 | - opened |
| 20 | - reopened |
| 21 | - synchronize |
| 22 | |
| 23 | jobs: |
| 24 | validate_pr: |
| 25 | runs-on: ubuntu-latest |
| 26 | |
| 27 | permissions: |
| 28 | contents: read |
| 29 | pull-requests: write |
| 30 | |
| 31 | steps: |
| 32 | - run: | |
| 33 | prTitle="$(gh api graphql -F owner=$OWNER -F name=$REPO -F pr_number=$PR_NUMBER -f query=' |
| 34 | query($name: String!, $owner: String!, $pr_number: Int!) { |
| 35 | repository(owner: $owner, name: $name) { |
| 36 | pullRequest(number: $pr_number) { |
| 37 | title |
| 38 | } |
| 39 | } |
| 40 | }')" |
| 41 | |
| 42 | if [[ "${prTitle}" == *"Personal/"* ]]; then |
| 43 | gh pr comment $PR_URL --body "⚠️ Please add a meaningful PR title (remove the 'Personal/' prefix from the title)." |
| 44 | echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV |
| 45 | fi |
| 46 | |
| 47 | env: |
| 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 49 | OWNER: ${{ github.repository_owner }} |
| 50 | PR_NUMBER: ${{ github.event.number }} |
| 51 | PR_URL: ${{ github.event.pull_request.html_url }} |
| 52 | REPO: ${{ github.event.repository.name }} |
| 53 | |
| 54 | - name: Check for Validation Errors |
| 55 | if: env.VALIDATION_ERROR |
| 56 | uses: actions/github-script@v7 |
| 57 | with: |
| 58 | script: | |
| 59 | core.setFailed('PR Formatting Validation Check Failed!') |
| 60 | |