Repository navigation
Expand file tree
/
Copy pathpull-request-formatting-validator.yml
More file actions
76 lines (65 loc) · 2.58 KB
/
Copy pathpull-request-formatting-validator.yml
File metadata and controls
76 lines (65 loc) · 2.58 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# This workflow validates basic pull request formatting requirements are met.
#
# The title check runs without secrets. When it fails, the pull request number is uploaded so the
# "Validate Pull Request Formatting Post" workflow can post a comment.
#
# 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:
types:
- edited
- opened
- reopened
- synchronize
permissions:
contents: read
jobs:
validate_pr:
runs-on: ubuntu-latest
steps:
- name: Validate Pull Request Title
id: validate
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
personal_prefix=false
default_sync_title=false
if [[ "${PR_TITLE,,}" == *"personal/"* ]]; then
echo "::error::Please add a meaningful PR title (remove the 'Personal/' prefix from the title)."
personal_prefix=true
fi
if [[ "${PR_TITLE}" == "Repo File Sync: synced file(s) with microsoft/mu_devops" ]]; then
echo "::error::Please add a meaningful PR title (update the default file sync title)."
default_sync_title=true
fi
violation=false
if [[ "${personal_prefix}" == "true" || "${default_sync_title}" == "true" ]]; then
violation=true
mkdir metadata
printf '{"pr_number": %s, "personal_prefix": %s, "default_sync_title": %s}\n' \
"${PR_NUMBER}" "${personal_prefix}" "${default_sync_title}" > metadata/pr-metadata.json
fi
echo "violation=${violation}" >> "$GITHUB_OUTPUT"
- name: Upload PR Metadata
if: steps.validate.outputs.violation == 'true'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: pr-formatting-metadata
path: metadata/pr-metadata.json
overwrite: true
retention-days: 5
- name: Check for Validation Errors
if: steps.validate.outputs.violation == 'true'
run: |
echo "::error::PR Formatting Validation Check Failed!"
exit 1