Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Scheduled/periodic runs #70

Closed
benschwarz opened this issue Sep 14, 2020 · 4 comments · Fixed by #72
Closed

Feature: Scheduled/periodic runs #70

benschwarz opened this issue Sep 14, 2020 · 4 comments · Fixed by #72

Comments

@benschwarz
Copy link
Member

At the moment image-actions runs only when you've updated a pull request. Images are optimised and committed inline.
In most cases, this works quite well, but there are some drawbacks to this approach:

  • The next time you push to your PR, you'll need to pull first (because image-actions has produced a new commit)
  • By adding a commit, some test suites will run (again), clogging up builds for a longer duration
  • If you're displeased with the image compression (or some other issue), you're not able to choose if you want the changes or not. This isn't something I've faced personally, but either way the fix (remove the commit and then turn off image actions) isn't very straightforward and feels like busy work.

By using GitHub Actions scheduler, image-actions could:

  • Be run periodically (as often as you like - daily, weekly, monthly, etc)
  • If there's optimisations, a pull request could be created -- rather than interrupting WIP (similar to dependabot or other tools)

This issue stands as a mark of intent to implement. If anyone has the bandwidth to help, please let me know or submit a PR 🏆

@tunetheweb
Copy link
Contributor

tunetheweb commented Sep 14, 2020

When #54 is merged then this can be done with an action something like this:

name: Compress images every morning at 8am, opening PRs if necessary
on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  '* 8 * * *'
jobs:
  build:
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master

      - name: Compress Images
        id: calibre
        uses: calibreapp/image-actions@master
        with:
          githubToken: ${{ secrets.GITHUB_TOKEN }}
          compressOnly: true

      - name: Create New Pull Request
        uses: peter-evans/create-pull-request@master
        with:
          title: Compressed Images
          branch-suffix: timestamp
          commit-message: Compressed Images
          body: ${{ steps.calibre.outputs.markdown }}

@KshitijDarekar
Copy link

@tunetheweb @benschwarz
I have a question - will Github Image Action compress an already-compressed image? Let's say we have scheduled Image action to run every Sunday at 11:00 pm, so every time will it compress an image that is already optimized?

@tunetheweb
Copy link
Contributor

It will attempt to recompress it, but if it doesn't find significant savings then it will ignore it. This is also what happens if you upload an already optimised image.

I run this ever Sunday in my repo, and though the first few runs spotted a few uncompressed image after that it settled and now basically never alerts unless I really add an uncompressed image to the repo: https://github.com/HTTPArchive/almanac.httparchive.org/actions/workflows/compress-images.yml

@KshitijDarekar
Copy link

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants