microsoft/mu_feature_ffa
Publicmirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable
.github/workflows/pull-request-formatting-validator.yml
63lines · 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_target: |
| 17 | types: |
| 18 | - edited |
| 19 | - opened |
| 20 | - reopened |
| 21 | - synchronize |
| 22 | |
| 23 | jobs: |
| 24 | validate_pr: |
| 25 | runs-on: ubuntu-latest |
| 26 | |
| 27 | steps: |
| 28 | - name: Generate Token |
| 29 | id: app-token |
| 30 | uses: actions/create-github-app-token@v2 |
| 31 | with: |
| 32 | app-id: ${{ vars.MU_ACCESS_APP_ID }} |
| 33 | private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }} |
| 34 | owner: ${{ github.repository_owner }} |
| 35 | |
| 36 | - run: | |
| 37 | prTitle="$(gh api graphql -F owner=$OWNER -F name=$REPO -F pr_number=$PR_NUMBER -f query=' |
| 38 | query($name: String!, $owner: String!, $pr_number: Int!) { |
| 39 | repository(owner: $owner, name: $name) { |
| 40 | pullRequest(number: $pr_number) { |
| 41 | title |
| 42 | } |
| 43 | } |
| 44 | }')" |
| 45 | |
| 46 | if [[ "${prTitle}" == *"Personal/"* ]]; then |
| 47 | gh pr comment $PR_URL --body "⚠️ Please add a meaningful PR title (remove the 'Personal/' prefix from the title)." |
| 48 | echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV |
| 49 | fi |
| 50 | |
| 51 | env: |
| 52 | GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
| 53 | OWNER: ${{ github.repository_owner }} |
| 54 | PR_NUMBER: ${{ github.event.number }} |
| 55 | PR_URL: ${{ github.event.pull_request.html_url }} |
| 56 | REPO: ${{ github.event.repository.name }} |
| 57 | |
| 58 | - name: Check for Validation Errors |
| 59 | if: env.VALIDATION_ERROR |
| 60 | uses: actions/github-script@v7 |
| 61 | with: |
| 62 | script: | |
| 63 | core.setFailed('PR Formatting Validation Check Failed!') |
| 64 | |