https://github.com/doist/optimize-images-action
GitHub Action that applies lossless image optimization.
https://github.com/doist/optimize-images-action
Last synced: about 1 year ago
JSON representation
GitHub Action that applies lossless image optimization.
- Host: GitHub
- URL: https://github.com/doist/optimize-images-action
- Owner: Doist
- License: mit
- Created: 2021-07-07T00:46:26.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-03-03T19:09:15.000Z (over 3 years ago)
- Last Synced: 2025-03-06T13:39:16.929Z (over 1 year ago)
- Language: Ruby
- Size: 17.6 KB
- Stars: 3
- Watchers: 10
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitHub Action: Optimize Images
GitHub Action that applies lossless image optimization.
## Usage
```yaml
- uses: doist/optimize-images-action@v2
with:
# Colon-delimited list of files and directories to process, e.g., "assets".
input: "**/*"
# Colon-delimited list of files and directories to ignore, e.g., "store:assets/originals".
ignore: ""
```
The values shown are the defaults. For paths, glob patterns using `*`, `**` and `?` are supported.
## Examples
Here's a workflow that optimizes images when they change on the main branch, and submits a pull request with the changes:
```yaml
name: Optimize images and PR
on:
push:
branches:
- main
paths:
- "**.png"
- "**.jpe?g"
- "**.svg"
- "**.gif"
jobs:
optimize-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Optimize images
id: optimize-images
uses: Doist/optimize-images-action@v2
- name: Create pull request
uses: peter-evans/create-pull-request@v3
with:
commit-message: "Optimize images (lossless)"
delete-branch: true
body: ${{ steps.optimize-images.outputs.summary }}
```
Or one that optimizes images included in a pull request to the main branch and commits the changes:
```yaml
name: Optimize images and commit
on:
pull_request:
branches:
- main
paths:
- "**.png"
- "**.jpe?g"
- "**.svg"
- "**.gif"
jobs:
optimize-images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Optimize images
uses: Doist/optimize-images-action@v2
- name: Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Optimize images (lossless)"
```
## Acknowledgements
This action builds upon the excellent [image_optim](https://github.com/toy/image_optim) by [@toy](https://github.com/toy).
## License
[MIT License](https://github.com/Doist/optimize-images-action/blob/main/LICENSE).