GitHub Action
Tinify Image Action
v1.4.0
Latest version
GitHub Action to compress and resize images with the Tinify API.
- filters PNG, JPEG, and WebP files in a commit or pull request
- optionally scales images proportionally
- sets Exif metadata to prevent duplicate compressions
- pushes commit with compression metrics
For example, on pull_request
events with modified files inside the static
directory:
name: Compress Images
on:
pull_request:
paths:
- 'static/**'
jobs:
compress:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: namoscato/action-tinify@v1
with:
api_key: ${{ secrets.TINIFY_API_KEY }}
The following webhook events are supported:
pull_request
push
Important
In pull request contexts, actions/checkout
checkouts a merge commit by default. You must checkout the pull request HEAD commit by overriding the ref
input as illustrated above and as noted in their documentation.
Events triggered by a default GITHUB_TOKEN
commit will not create a new workflow run to prevent accidental recursion.
If you are sure that you want the compression commit to trigger a workflow run, you can configure actions/checkout
with a personal access token:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
input | description |
---|---|
api_key |
Required Tinify API key (create one here) |
github_token |
Repository GITHUB_TOKEN or personal access token secret; defaults to github.token |
commit_user_name |
Git user.name, defaults to github.actor |
commit_user_email |
Git user.email, defaults to <github.actor>@users.noreply.github.com |
commit_message |
Custom commit message, defaults to Compress image(s) |
resize_width |
Maximum target image width |
resize_height |
Maximum target image height |