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
81 changes: 81 additions & 0 deletions .github/workflows/optimize-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Optimize Images

# **What it does**: Automatically compress and optimize images.
# **Why we have it**: Reduces bandwidth needs of app and repo.

on:
push:
branches:
- main
paths:
- '**.jpg'
- '**.jpeg'
- '**.png'
- '**.webp'
- '**.svg'
pull_request:
paths:
- '**.jpg'
- '**.jpeg'
- '**.png'
- '**.webp'
- '**.svg'
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Optimize Images
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
# Only run on main repo and PRs that match the main repo
if: >
github.repository == 'fastify/website' && (github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)


steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
ref: main

- name: Optimize svg images
run: |
npx svgo -rf ./static/img

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v20
id: verify-changed-files
with:
files: |
**/*.svg

- name: Compress images
id: calibre
uses: calibreapp/image-actions@main
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
jpegQuality: '100'
pngQuality: '100'
webpQuality: '100'
# For non-Pull Requests, run in compressOnly mode and PR after
compressOnly: ${{ github.event_name != 'pull_request' }}

- name: Create pull request
# If it is not a Pull Request then commit any changes as a new PR
if: >
github.event_name != 'pull_request' && (steps.calibre.outputs.markdown != '' || steps.verify-changed-files.outputs.files_changed == 'true')


uses: peter-evans/create-pull-request@v7
with:
title: 'chore: auto-compress images'
branch-suffix: timestamp
commit-message: 'chore: auto-compress images'
body: ${{ steps.calibre.outputs.markdown }}
2 changes: 1 addition & 1 deletion static/img/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 1 addition & 12 deletions static/img/logos/fastify-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading