-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👷 Add GitHub workflow to optimize PNG files (#31)
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |