Add Azure Front Door support to static assets deploy action #661
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Validate Workflow Naming | |
on: | |
pull_request: | |
paths: | |
- '.github/workflows/**' | |
jobs: | |
validate-naming: | |
name: Validate Workflow Naming Convention | |
runs-on: ubuntu-latest | |
concurrency: | |
group: ${{ github.workflow }}-ci | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
actions: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Validate workflow file naming convention | |
env: | |
BASE_REF: ${{ github.event.pull_request.base.ref }} | |
HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
run: | | |
set -eu | |
echo "Checking naming convention for new workflow files in .github/workflows directory" | |
BASE_BRANCH="origin/$BASE_REF" | |
HEAD_BRANCH="origin/$HEAD_REF" | |
echo "- FROM Base ref: $BASE_BRANCH" | |
echo "- TO Head ref: $HEAD_BRANCH" | |
# Find all new files in the .github/workflows directory that are added in the pull request | |
NEW_FILES=$(git diff --name-only --diff-filter=A $BASE_BRANCH...$HEAD_BRANCH | grep '^.github/workflows/' || true) | |
if [ -z "$NEW_FILES" ]; then | |
echo "No new workflow files detected. Skipping validation." | |
exit 0 | |
fi | |
# Define the naming pattern | |
# Pattern is: [_]<scope>-<type>-<description>[-vN].yaml | |
NAMING_PATTERN='^(_)?(cron|build|validate|release)-(docker|typescript|terraform|changesets|docusaurus|bash|go|azure|aws)-[a-z0-9-]+(-v[0-9]+)?\.yaml$' | |
# Check each new file | |
for FILE in $NEW_FILES; do | |
FILE_NAME=$(basename "$FILE") | |
if ! [[ "$FILE_NAME" =~ ^_ ]]; then | |
# If is a reusable workflow (don't start starts with '_'), ensure '-vN' is present | |
if ! [[ "$FILE_NAME" =~ -v[0-9]+\.yaml$ ]]; then | |
echo "Error: Internal workflow file '$FILE_NAME' must include '-vN' at the end." | |
echo "Example: validate-azure-example-v1.yaml" | |
exit 1 | |
fi | |
fi | |
if ! [[ "$FILE_NAME" =~ $NAMING_PATTERN ]]; then | |
echo "Error: File '$FILE_NAME' does not follow the naming convention." | |
echo "Required format: [_]<scope>-<type>-<description>[-vN].yaml" | |
echo " - <_> only if is an internal workflow" | |
echo " - <scope> must be one of: cron, build, validate, release" | |
echo " - <type> must be one of: docker, typescript, terraform, changesets, docusaurus, bash, go, azure, aws" | |
echo " - <description> must be lowercase divided by hyphens (-)" | |
echo " - <vN> where N is a major version (required if is a reusable workflow)" | |
echo " - file extension must be .yaml" | |
echo "Example: validate-bash-script-checks.yaml or _cron-azure-backup-v1.yaml" | |
exit 1 | |
fi | |
done | |
echo "All new workflow files follow the naming convention." |