Skip to content

2608 GitHub workflow updates [Rebase & FF] #7778

2608 GitHub workflow updates [Rebase & FF]

2608 GitHub workflow updates [Rebase & FF] #7778

# This workflow validates basic pull request formatting requirements are met.

Check warning on line 1 in .github/workflows/pull-request-formatting-validator.yml

View workflow run for this annotation

GitHub Actions / Validate Pull Request Formatting

Workflow execution policy warning (evaluate mode)

On November 2, 2026, GitHub will restrict `pull_request_target` on public repositories by default. To continue allowing the event trigger, configure an Actions policy. Learn more: https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target
#
# 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
steps:
- name: Generate Token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ vars.MU_ACCESS_APP_ID }}
private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}
- 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
}
}
}' --jq '.data.repository.pullRequest.title')"
comments="$(gh api "repos/${OWNER}/${REPO}/issues/${PR_NUMBER}/comments" --paginate --jq '.[].body')"
if [[ "${prTitle}" == *"Personal/"* ]]; then
if ! echo "${comments}" | grep -qF '<!-- pr-val-personal -->'; then
gh pr comment $PR_URL --body "<!-- pr-val-personal -->⚠️ Please add a meaningful PR title (remove the 'Personal/' prefix from the title)."
fi
echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV
fi
if [[ "${prTitle}" == "Repo File Sync: synced file(s) with microsoft/mu_devops" ]]; then
if ! echo "${comments}" | grep -qF '<!-- pr-val-sync-title -->'; then
gh pr comment $PR_URL --body "<!-- pr-val-sync-title -->⚠️ Please add a meaningful PR title (update the default file sync title)."
fi
echo 'VALIDATION_ERROR=true' >> $GITHUB_ENV
fi
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.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@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
core.setFailed('PR Formatting Validation Check Failed!')