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: | if [ -z "${{ steps.changed.outputs.added_modified }}" ]; then echo "No files changed, skipping" exit 0 fi 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"