GitHub Action Check Folder Name - SSWConsulting/SSW.Rules.Content GitHub Wiki

Check Folder Name

This GitHub Action automatically checks whether the folder name of a rule matches its uri (as defined in rule.md). If there's a mismatch, it renames the folder and updates the redirects field in rule.md to avoid broken links.

When It Runs

This workflow runs on pull requests that modify any rule.md file. It gets triggered when:

  • A PR is opened

  • A PR is updated (synchronized)

What It Does

  1. Checks out the pull request code
    Ensures itโ€™s working with the latest PR branch and all changes

  2. Checks for modified rule.md files
    Uses git diff to determine whether any rule.md file has changed compared to origin/main.

  3. Runs folder renaming logic
    If a modified rule.md is found, it runs a shell script (.workflow/rename-folders.sh) that:

    • Reads the uri: field from each changed rule.md

    • Compares it to the folder name

    • Renames the folder if there's a mismatch

    • Updates the redirects: field in rule.md to include the old folder name, so previous URLs still work

  4. Commits and pushes the changes
    If any folders were renamed, it automatically commits and pushes the changes back to the PR branch with the message:
    "Rename folder to match URI"