Skip to content

Commit

Permalink
👷 Add GitHub workflow to optimize PNG files (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
nebuIr committed Jul 31, 2022
1 parent ce62466 commit 66b6c14
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/optimize.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 66b6c14

Please sign in to comment.