From b415397a5a5420f7911332c900fe4322dd40b66b Mon Sep 17 00:00:00 2001 From: Gregory Campbell Date: Wed, 3 Jun 2026 21:53:46 -0400 Subject: [PATCH] ci(images): add workflow to optimize images on asset changes --- .github/workflows/optimize-images.yml | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/optimize-images.yml diff --git a/.github/workflows/optimize-images.yml b/.github/workflows/optimize-images.yml new file mode 100644 index 000000000..1ad6869c8 --- /dev/null +++ b/.github/workflows/optimize-images.yml @@ -0,0 +1,48 @@ +name: Optimize images + +on: + push: + branches: [ main, master ] + paths: + - 'src/assets/**' + - 'assets/**' + pull_request: + paths: + - 'src/assets/**' + - 'assets/**' + workflow_dispatch: {} + +jobs: + optimize: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run image optimizer + run: npm run optimize-images + + - name: Commit optimized images + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add public/images || true + if ! git diff --staged --quiet; then + git commit -m "chore(images): add optimized WebP images [skip ci]" || echo "no changes to commit" + git push + else + echo "No optimized images to commit" + fi