From d98a90bccce63632cb86faae3654921c7bf89162 Mon Sep 17 00:00:00 2001 From: Vince Picone Date: Mon, 15 Feb 2021 13:02:16 -0600 Subject: [PATCH] feat: add on demand and scheduled image processing (#2140) This updates the image processing to allow for running on-demand and scheduled (once a week on Sunday). This prevents the bot from cluttering (sometimes unrelated) pull requests, which has been a source of confusion during code reviews. After manually triggering the action in a fork, the bot successfully opened a PR shaving off 10mb from the images. --- .github/workflows/process-images.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/process-images.yml b/.github/workflows/process-images.yml index d0b480e592e..f9d3742faf7 100644 --- a/.github/workflows/process-images.yml +++ b/.github/workflows/process-images.yml @@ -1,18 +1,28 @@ -name: Compress images +# Compress images on demand (workflow_dispatch), and at 11pm every Sunday (schedule). +# Open a Pull Request if any images can be compressed. +name: Compress Images on: - pull_request: - paths: - - '**.jpg' - - '**.png' - - '**.webp' + workflow_dispatch: + schedule: + - cron: '00 23 * * 0' jobs: build: name: calibreapp/image-actions runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@master + uses: actions/checkout@v2 - name: Compress Images - uses: calibreapp/image-actions@master + id: calibre + uses: calibreapp/image-actions@main with: githubToken: ${{ secrets.GITHUB_TOKEN }} + compressOnly: true + - name: Create New Pull Request If Needed + if: steps.calibre.outputs.markdown != '' + uses: peter-evans/create-pull-request@v3 + with: + title: Compressed Images Nightly + branch-suffix: timestamp + commit-message: Compressed Images + body: ${{ steps.calibre.outputs.markdown }}