Skip to content

Commit 1080608

Browse files
Repo File Sync: Add PR formatting validator workflow (#91)
synced local file(s) with [OpenDevicePartnership/patina-devops](https://github.com/OpenDevicePartnership/patina-devops). 🤖: View the [Repo File Sync Configuration File](https://github.com/OpenDevicePartnership/patina-devops/blob/main/.sync/Files.yml) to see how files are synced. --- This PR was created automatically by the [repo-file-sync-action](https://github.com/BetaHuhn/repo-file-sync-action) workflow run [#24444711131](https://github.com/OpenDevicePartnership/patina-devops/actions/runs/24444711131) Signed-off-by: Patina Automation Bot <patina@microsoft.com> Co-authored-by: patina-automation[bot] <196234736+patina-automation[bot]@users.noreply.github.com>
1 parent c0e0124 commit 1080608

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# This workflow validates basic pull request formatting requirements are met.
2+
#
3+
# NOTE: This file is automatically synchronized from Patina DevOps. Update the original file there
4+
# instead of the file in this repo.
5+
#
6+
# - Patina DevOps Repo: https://github.com/OpenDevicePartnership/patina-devops
7+
# - File Sync Settings: https://github.com/OpenDevicePartnership/patina-devops/blob/main/.sync/Files.yml
8+
##
9+
# Copyright (c) Microsoft Corporation.
10+
# SPDX-License-Identifier: Apache-2.0
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@v3
31+
with:
32+
app-id: ${{ secrets.PATINA_AUTOMATION_APPLICATION_ID }}
33+
private-key: ${{ secrets.PATINA_AUTOMATION_APPLICATION_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}" == "Repo File Sync: synced file(s) with OpenDevicePartnership/patina-devops" ]]; then
49+
if ! echo "${comments}" | grep -qF '<!-- pr-val-sync-title -->'; then
50+
gh pr comment $PR_URL --body "<!-- pr-val-sync-title -->⚠️ Please add a meaningful PR title (update the default file sync title)."
51+
fi
52+
echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV
53+
fi
54+
55+
env:
56+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
57+
OWNER: ${{ github.repository_owner }}
58+
PR_NUMBER: ${{ github.event.number }}
59+
PR_URL: ${{ github.event.pull_request.html_url }}
60+
REPO: ${{ github.event.repository.name }}
61+
62+
- name: Check for Validation Errors
63+
if: env.VALIDATION_ERROR
64+
uses: actions/github-script@v8
65+
with:
66+
script: |
67+
core.setFailed('PR Formatting Validation Check Failed!')

0 commit comments

Comments
 (0)