diff --git a/.github/workflows/optimize-images.yml b/.github/workflows/optimize-images.yml new file mode 100644 index 00000000..7e06fe80 --- /dev/null +++ b/.github/workflows/optimize-images.yml @@ -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 }} diff --git a/static/img/logo.svg b/static/img/logo.svg index 9db6d0d0..2f385b7c 100644 --- a/static/img/logo.svg +++ b/static/img/logo.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/logos/fastify-black.svg b/static/img/logos/fastify-black.svg index 921b8a19..c90a83f1 100644 --- a/static/img/logos/fastify-black.svg +++ b/static/img/logos/fastify-black.svg @@ -1,12 +1 @@ - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/logos/fastify-white.svg b/static/img/logos/fastify-white.svg index a465ff87..f88361f6 100644 --- a/static/img/logos/fastify-white.svg +++ b/static/img/logos/fastify-white.svg @@ -1,12 +1 @@ - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/logos/openjsf.svg b/static/img/logos/openjsf.svg index 03421af5..a07a2dfe 100644 --- a/static/img/logos/openjsf.svg +++ b/static/img/logos/openjsf.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/organizations/handsontable.svg b/static/img/organizations/handsontable.svg index 45340a03..6989f15a 100644 --- a/static/img/organizations/handsontable.svg +++ b/static/img/organizations/handsontable.svg @@ -1,4 +1 @@ - - - - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/organizations/hospitalrun.svg b/static/img/organizations/hospitalrun.svg index 6c06c6ce..445388a7 100644 --- a/static/img/organizations/hospitalrun.svg +++ b/static/img/organizations/hospitalrun.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/organizations/mercedes-benz.svg b/static/img/organizations/mercedes-benz.svg index b65fc368..d2771089 100644 --- a/static/img/organizations/mercedes-benz.svg +++ b/static/img/organizations/mercedes-benz.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/static/img/organizations/nearform.svg b/static/img/organizations/nearform.svg index 1abcc0f3..3497720a 100644 --- a/static/img/organizations/nearform.svg +++ b/static/img/organizations/nearform.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/static/img/organizations/platformatic.svg b/static/img/organizations/platformatic.svg index d21a08eb..6573ab77 100644 --- a/static/img/organizations/platformatic.svg +++ b/static/img/organizations/platformatic.svg @@ -1,118 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/static/img/organizations/val-town.svg b/static/img/organizations/val-town.svg index 75f2ebf6..eeb51ef3 100644 --- a/static/img/organizations/val-town.svg +++ b/static/img/organizations/val-town.svg @@ -1,19 +1 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file