Performance 2024 Chapter #2449
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################### | |
## Calibre Image Action ## | |
########################### | |
# | |
# This runs the calibre GitHub action to compress our images | |
# | |
# This Action has a few different methoids for running: | |
# 1) For Pull Requests from and to the main repo it can run and update the PR | |
# 2) For pushes to main, it will run and create a new PR. This captures PR from | |
# Forks. | |
# 3) It also runs every sunday at 11pm in case anything else sneaks in or any | |
# improvements are added to Calibre. This will also open a PR if necessary. | |
# 4) Finally it can be kicked off manually and it will open a PR if necessary. | |
name: Compress Images | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '**.jpg' | |
- '**.jpeg' | |
- '**.png' | |
- '**.webp' | |
pull_request: | |
paths: | |
- '**.jpg' | |
- '**.jpeg' | |
- '**.png' | |
- '**.webp' | |
workflow_dispatch: | |
schedule: | |
# Run a full compression every Sunday at 11pm to start the week right | |
- cron: '00 23 * * 0' | |
jobs: | |
build: | |
name: Compress All Images | |
runs-on: ubuntu-20.04 | |
# Only run on main repo on and PRs that match the main repo | |
if: | | |
github.repository == 'HTTPArchive/almanac.httparchive.org' && | |
(github.event_name != 'pull_request' || | |
github.event.pull_request.head.repo.full_name == github.repository) | |
steps: | |
- name: Checkout Branch | |
uses: actions/checkout@v4 | |
- name: Run Image Compression | |
id: calibre | |
uses: calibreapp/image-actions@main | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
compressOnly: ${{ github.event_name != 'pull_request' }} | |
jpegProgressive: true | |
- name: Create Pull Request | |
# If it's not a pull request then commit any changes as a new PR | |
if: | | |
github.event_name != 'pull_request' && | |
steps.calibre.outputs.markdown != '' | |
id: cpr | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
title: Auto Compress Images | |
branch-suffix: timestamp | |
commit-message: Compress Images | |
body: ${{ steps.calibre.outputs.markdown }} | |
labels: performance | |
- name: Check Outputs | |
# If it's not a pull request then commit any changes as a new PR | |
if: steps.cpr.outputs.pull-request-number != '' | |
run: echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" |