Skip to content

HEIC to JPG

HEIC to JPG #27

Workflow file for this run

name: List Images in JSON
on:
push:
paths:
- "img/**"
- ".github/workflows/list-img.yml"
workflow_dispatch:
jobs:
convert:
runs-on: ubuntu-latest
steps:
- name: 檢出原始碼
uses: actions/checkout@v2
- name: 設定 Node.js
uses: actions/setup-node@v2
with:
node-version: "20.10.0"
- name: 安裝套件
run: |
sudo apt-get install -y webp
sudo apt-get install -y libheif-examples
- name: Install ImageMagick
run: sudo apt-get install -y imagemagick
- name: 轉檔成 JPG (處理 HEIC)
run: |
find img -type f -name '*.heic' -exec sh -c 'heif-convert "$1" "${1%.*}.jpg"' _ {} \;
- name: 轉檔成 WebP
run: |
find img -type d -exec mkdir -p converted/{} \;
find img -type f \( -name '*.png' -o -name '*.jpg' -o -name '*.JPG' -o -name '*.jpeg' \) -exec sh -c 'cwebp -q 50 "$1" -o "converted/${1%.*}.webp"' _ {} \;
find converted -type f -name '*.webp' -exec sh -c 'convert "$1" -resize x1000 "$1"' _ {} \;
- name: 列出圖片
run: node ./list-img.js
- name: 提交變更
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
if git diff --staged --quiet; then
echo "No changes"
else
git pull
git commit -m "🖼️更新圖片列表"
git push
fi