diff --git a/.github/workflows/optimize.yml b/.github/workflows/optimize.yml new file mode 100644 index 00000000..65133307 --- /dev/null +++ b/.github/workflows/optimize.yml @@ -0,0 +1,46 @@ +name: ⚡ Optimize PNG files + +on: + push: + branches: + - mc/* + paths: + - '**/*.png' + +jobs: + build: + name: ⚡ Optimize PNG files + runs-on: ubuntu-latest + steps: + - name: 🚚 Get latest code + uses: actions/checkout@v3 + + - name: 📦 Install oxipng + uses: baptiste0928/cargo-install@v1 + with: + crate: oxipng + version: latest + + - name: 🧾 Get changed PNG files + id: changed-files + uses: tj-actions/changed-files@v23.2 + with: + files: '**/*.png' + + - name: ⚡ Optimize PNG files + run: oxipng -sZ -o 3 -i 0 ${{ steps.changed-files.outputs.all_changed_files }} + + - name : 🧾 Get optimized PNG files + id: optimized-files + run: echo "::set-output name=all_optimized_files::$(git status --porcelain | sed s/^...// | sed -z 's/\n/%0A/g;s/%0A$/\n/')" + + - name: ⬆️ Commit and push changes + if: ${{ steps.optimized-files.outputs.all_optimized_files }} + uses: swinton/commit@v2.x + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: | + ${{ steps.optimized-files.outputs.all_optimized_files }} + commit-message: ':zap: Optimize PNG files' + ref: ${{ github.ref }} \ No newline at end of file