microsoft/mu_feature_ffa

Public

mirrored from https://github.com/microsoft/mu_feature_ffaAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
main

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/workflows/pull-request-formatting-validator.yml

74lines · 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
13name: Validate Pull Request Formatting
14
15on:
16 pull_request_target:
17 types:
18 - edited
19 - opened
20 - reopened
21 - synchronize
22
23jobs:
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@v3
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 }' --jq '.data.repository.pullRequest.title')"
45
46 comments="$(gh api "repos/${OWNER}/${REPO}/issues/${PR_NUMBER}/comments" --paginate --jq '.[].body')"
47
48 if [[ "${prTitle}" == *"Personal/"* ]]; then
49 if ! echo "${comments}" | grep -qF '<!-- pr-val-personal -->'; then
50 gh pr comment $PR_URL --body "<!-- pr-val-personal -->⚠️ Please add a meaningful PR title (remove the 'Personal/' prefix from the title)."
51 fi
52 echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV
53 fi
54
55 if [[ "${prTitle}" == "Repo File Sync: synced file(s) with microsoft/mu_devops" ]]; then
56 if ! echo "${comments}" | grep -qF '<!-- pr-val-sync-title -->'; then
57 gh pr comment $PR_URL --body "<!-- pr-val-sync-title -->⚠️ Please add a meaningful PR title (update the default file sync title)."
58 fi
59 echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV
60 fi
61
62 env:
63 GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
64 OWNER: ${{ github.repository_owner }}
65 PR_NUMBER: ${{ github.event.number }}
66 PR_URL: ${{ github.event.pull_request.html_url }}
67 REPO: ${{ github.event.repository.name }}
68
69 - name: Check for Validation Errors
70 if: env.VALIDATION_ERROR
71 uses: actions/github-script@v9
72 with:
73 script: |
74 core.setFailed('PR Formatting Validation Check Failed!')
75