forked from nebuIr/Default-Dark-Mode
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (46 loc) · 1.48 KB
/
optimize.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: ⚡ Optimize PNG files
on:
push:
branches:
- '[0-9].[0-9]+**'
- snapshot
paths:
- '**/*.png'
jobs:
build:
name: ⚡ Optimize PNG files
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📦 Install oxipng
uses: baptiste0928/cargo-install@v2
with:
crate: oxipng
version: latest
- name: 🧾 Get changed PNG files
id: changed-files
uses: tj-actions/changed-files@v41
with:
since_last_remote_commit: "true"
files: "**/*.png"
- name: ⚡ Optimize PNG files
run: oxipng -sZ -o 3 -i 0 --ng ${{ steps.changed-files.outputs.all_changed_files }}
- name : 🧾 Get optimized PNG files
id: optimized-files
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "all_optimized_files<<$EOF" >> $GITHUB_OUTPUT
echo "$(git status --porcelain | sed s/^...//)" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT
- 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 }}