2022-10-08 00:49:58 +01:00
|
|
|
name: "Optimize images with TinyPNG"
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
paths:
|
|
|
|
- "**.jpg"
|
|
|
|
- "**.jpeg"
|
|
|
|
- "**.png"
|
|
|
|
- "**.webp"
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
python-version: ["3.10"]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
|
|
|
|
- id: changed
|
|
|
|
uses: jitterbit/get-changed-files@v1
|
|
|
|
with:
|
|
|
|
format: "csv"
|
|
|
|
|
|
|
|
- name: Set up Python ${{ matrix.python-version }}
|
|
|
|
uses: actions/setup-python@v4
|
|
|
|
with:
|
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pip install tinify tqdm python-dotenv
|
|
|
|
|
|
|
|
- name: Tinify Images
|
|
|
|
run: |
|
2023-03-27 08:48:55 +01:00
|
|
|
if [ -z "${{ steps.changed.outputs.added_modified }}" ]; then
|
|
|
|
echo "No files changed, skipping"
|
|
|
|
exit 0
|
|
|
|
fi
|
2022-10-08 00:49:58 +01:00
|
|
|
python .github/scripts/tinify_images.py \
|
|
|
|
-d images \
|
|
|
|
-ff ${{ steps.changed.outputs.added_modified }} \
|
|
|
|
-k ${{ secrets.TINIFY_API_KEY }} \
|
|
|
|
|| exit 1
|
|
|
|
|
|
|
|
- name: Commit changes
|
|
|
|
uses: EndBug/add-and-commit@v9
|
|
|
|
with:
|
|
|
|
default_author: github_actions
|
|
|
|
message: "Optimize images with TinyPNG"
|