Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,35 @@ jobs:

- name: Format check
run: pnpm format:check


lint_images:
name: Lint images
runs-on: ubuntu-latest
steps:
- name: Checkout Source code
uses: actions/checkout@v6

- name: Get changed unoptimized image files in sources
id: changed-files
uses: tj-actions/changed-files@v47
with:
files: |
sources/**/*.{png,jpg,jpeg,gif,bmp,tif,tiff,avif}
separator: "\n"

- name: Fail on unoptimized images
if: steps.changed-files.outputs.any_changed == 'true'
env:
UNOPTIMIZED_IMAGE_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
echo "Unoptimized images detected! Please run the following commands:"
echo ""
while IFS= read -r file_path; do
echo "pnpm opt:images $file_path"
done <<< "$UNOPTIMIZED_IMAGE_FILES"
echo ""
echo "Don't forget to change image paths to end with .webp in your Markdown."
echo "If you point the same command at a whole directory, it will convert "
echo "and optimize all images inside."
exit 1
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"lint:md:fix": "markdownlint '**/*.md' --fix",
"lint:code": "oxlint --type-aware",
"lint:code:fix": "oxlint --type-aware --fix",
"opt:images": "pnx --config.onlyBuiltDependencies=* @343dev/optimizt --webp",
"format": "oxfmt",
"format:check": "oxfmt --check",
"test:academy": "bats --print-output-on-failure -r .",
Expand Down
Loading