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