Sign inSign up

chabad360/image-actions

By chabad360

•Updated over 6 years ago

Image
0

188

chabad360/image-actions repository overview

⁠Image Actions

Image Actions automatically compress JPEG, PNG and WebP images in GitHub Pull Requests.

  • Fast, efficient and near-lossless compression
  • Uses the best image compression algorithms available: mozjpeg⁠ and libvips⁠
  • Configurable and extensible: use default settings or adapt to your needs
  • Runs in GitHub Actions⁠
  • Built by web performance experts at Calibre⁠; a performance monitoring platform

Preview of image-actions Pull Request comment

⁠Add Image Actions to your repository

  1. Open or create the .github/workflows/calibreapp-image-actions.yml file.
  2. Paste in the following:
name: Compress images
on: pull_request
jobs:
  build:
    name: calibreapp/image-actions
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@master

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

The GITHUB_TOKEN secret is automatically generated by GitHub⁠. This automatic token is scoped only to the repository that is currently running the action.⁠

⁠Configure Image Actions

By default, you probably don’t need to configure image-actions. However, if you’d like to ignore specific file paths, or change image compression options, read on.

Change the configuration options by adding arguments to the action:

- name: Compress Images
  uses: calibreapp/image-actions@master
  with:
    githubToken: ${{ secrets.GITHUB_TOKEN }}
    jpegQuality: "80"
    pngQuality: "80"
    webpQuality: "80"
    ignorePaths: "node_modules/**,build"
    # No spaces allowed

Previous versions of image-actions used .github/config/image-actions.yml for configuration. If you're still using that configuration method we suggest that you update it.

⁠Running the action only when images are changed

image-actions is designed to run for each Pull Request. In some repositories, images are seldom updated. To run the action only when images have changed, use GitHub Action’s on.push.paths⁠ workflow configuration:

name: Compress images
on: 
  pull_request:
    paths:
      - '**.jpg'
      - '**.png'
      - '**.webp'

The above workflow will only run when jpg, png or webp files are changed.

Tag summary

Content type

Image

Digest

Size

283.8 MB

Last updated

over 6 years ago

docker pull chabad360/image-actions