Skip to content

GitHub Action Check Extension Case

Chloe Lin [SSW] edited this page Jun 10, 2025 · 1 revision

This GitHub Action enforces a simple but important rule: image file extensions must be lowercase (e.g. .png, not .PNG). It runs automatically on pull requests to the main branch and will fail the workflow if any uppercase extensions are detected.

When It Runs

  • On every pull request targeting the main branch

What It Does

  1. Checks out the pull request branch
  2. Finds added files
    Detect which files were added in the pull request
  3. Runs the extension check
    The custom shell script loops through all added files and:
    • Extracts their file extension
    • Strips unwanted characters
    • Converts the extension to lowercase for comparison
    • If the file is an image (.png, .jpg, .jpeg, .gif, .svg, .webp) and has an uppercase extension, the script fails the job with an error: Error: Use lowercase file extensions

📌 Example

If someone adds example.JPG to a PR, this action will detect:

  • It’s an image
  • Its extension .JPG is uppercase
  • The job will fail with:

Clone this wiki locally