diff --git a/.gitea/workflows/compressimage.yml b/.gitea/workflows/compressimage.yml index ca10571..f927196 100644 --- a/.gitea/workflows/compressimage.yml +++ b/.gitea/workflows/compressimage.yml @@ -23,11 +23,9 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 - - - name: Debug Event - run: | - echo "Base: ${{ gitea.base_ref }}" - echo "Head: ${{ gitea.head_ref }}" + with: + fetch-depth: 0 + ref: ${{ gitea.head_ref }} # IMPORTANT - name: Install Image Tools run: | @@ -47,4 +45,23 @@ jobs: - name: Optimize PNG run: | find . -type f -iname "*.png" \ - -exec pngquant --force --ext .png --quality=75-90 {} \; \ No newline at end of file + -exec pngquant --force --ext .png --quality=75-90 {} \; + + # Commit changes if any + - name: Commit changes + run: | + git config --global user.name "CI Bot" + git config --global user.email "ci@local" + + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "chore: optimize images via CI" + else + echo "No changes to commit" + fi + + # Push back to PR branch + - name: Push changes + if: success() + run: | + git push origin HEAD:${{ gitea.head_ref }} \ No newline at end of file