From 12c4e9f1374aac50ded8f31bd03e15ca0a054414 Mon Sep 17 00:00:00 2001 From: dontshot Date: Mon, 6 Oct 2025 13:52:35 +0800 Subject: [PATCH 1/5] test: add benign file to check workflow --- img/benign-check.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 img/benign-check.txt diff --git a/img/benign-check.txt b/img/benign-check.txt new file mode 100644 index 0000000..1e7043d --- /dev/null +++ b/img/benign-check.txt @@ -0,0 +1 @@ +"benign test" From a12272666bfe62cb67bbc7054723c46d335e8913 Mon Sep 17 00:00:00 2001 From: dontshot Date: Mon, 6 Oct 2025 13:54:35 +0800 Subject: [PATCH 2/5] cleanup test file --- img/benign-check.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 img/benign-check.txt diff --git a/img/benign-check.txt b/img/benign-check.txt deleted file mode 100644 index 1e7043d..0000000 --- a/img/benign-check.txt +++ /dev/null @@ -1 +0,0 @@ -"benign test" From ef6050a6373c433f0e8bed2a83f24f313ab8dcc6 Mon Sep 17 00:00:00 2001 From: dontshot Date: Mon, 6 Oct 2025 14:18:40 +0800 Subject: [PATCH 3/5] test: upload benign black image to trigger workflow --- img/8.png | Bin 0 -> 123 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 img/8.png diff --git a/img/8.png b/img/8.png new file mode 100644 index 0000000000000000000000000000000000000000..8ed27786330ab16087c8aca0ffb122e8452603cd GIT binary patch literal 123 zcmeAS@N?(olHy`uVBq!ia0vp^>_E)O!3HFSxVM}Gaf*Z7ofy`glX(f`u%tWsIx;Y9 z?C1WI$O`0h7I;J!GcfQS24TkI`72U@f&!i{jv*4^$tej5Kh8HWGcZUhGBR$6)G`Ok OF?hQAxvX Date: Mon, 6 Oct 2025 17:13:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?test:=20=E5=8A=A0=E5=85=A5=20benign=20JS=20?= =?UTF-8?q?step?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/list-img.yml | 131 +++++++++++++++++---------------- test-write.js | 6 ++ 2 files changed, 74 insertions(+), 63 deletions(-) create mode 100644 test-write.js diff --git a/.github/workflows/list-img.yml b/.github/workflows/list-img.yml index 412ed14..0ea8a47 100644 --- a/.github/workflows/list-img.yml +++ b/.github/workflows/list-img.yml @@ -1,70 +1,75 @@ name: List Images in JSON on: - push: - paths: - - "img/**" - - ".github/workflows/list-img.yml" - workflow_dispatch: + push: + paths: + - "img/**" + - ".github/workflows/list-img.yml" + workflow_dispatch: jobs: - convert: - runs-on: ubuntu-latest - steps: - - name: 檢出原始碼 - uses: actions/checkout@v2 + 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: 設定 Node.js + uses: actions/setup-node@v2 + with: + node-version: "20.10.0" - - name: 安裝套件 - run: | - sudo apt-get update - sudo apt-get install -y webp libheif-examples imagemagick - sudo apt-get install -y ffmpeg - - name: 列出 HEIC 文件 - run: find img -type f -name '*.HEIC' - - name: HEIC to JPG - run: | - find img -type f -name '*.HEIC' -exec sh -c ' - output_file="${1%.*}.jpg" - heif-convert "$1" "$output_file" - # 確保轉換成功後刪除原始 HEIC 文件 - if [ -f "$output_file" ]; then - rm "$1" - fi - ' _ {} \; - - name: 刪除多餘過渡檔案 #heif-convert 有時候會產生一些黑白的輔助圖片,這裡不希望被加進圖庫 - run: find . -type f \( \( -name "*aux*" -a -name "*apple*" \) -o -name "*depth*" \) -delete - - name: JPG 轉檔成 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' -o -name '*.JPEG' \) -exec sh -c ' - converted_file="converted/${1%.*}.webp" - echo "@!#$converted_file" - ffmpeg -i "$1" -q 50 "$converted_file" - ' _ {} \; - find converted -type f -name '*.webp' -exec sh -c 'convert "$1" -resize x1000 "$1"' _ {} \; - - name: 移動已轉換的社團圖片到 converted/club (已存在者除外) - run: | - mkdir -p converted/club - if [ -d converted/img/club ] && compgen -G "converted/img/club/*" > /dev/null; then - cp -rv --update=none converted/img/club/* converted/club/ - rm -rf converted/img/club/* - fi - - 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 + - name: 安裝套件 + run: | + sudo apt-get update + sudo apt-get install -y webp libheif-examples imagemagick ffmpeg + + - name: 列出 HEIC 文件 + run: find img -type f -name '*.HEIC' + + - name: HEIC to JPG + run: | + find img -type f -name '*.HEIC' -exec sh -c ' + output_file="${1%.*}.jpg" + heif-convert "$1" "$output_file" + if [ -f "$output_file" ]; then rm "$1"; fi + ' _ {} \; + + - name: 刪除多餘過渡檔案 + run: find . -type f \( \( -name "*aux*" -a -name "*apple*" \) -o -name "*depth*" \) -delete + + - name: JPG 轉檔成 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' -o -name '*.JPEG' \) -exec sh -c ' + converted_file="converted/${1%.*}.webp" + ffmpeg -i "$1" -q 50 "$converted_file" + ' _ {} \; + find converted -type f -name '*.webp' -exec sh -c 'convert "$1" -resize x1000 "$1"' _ {} \; + + - name: 移動已轉換的社團圖片到 converted/club + run: | + mkdir -p converted/club + if [ -d converted/img/club ] && compgen -G "converted/img/club/*" > /dev/null; then + cp -rv --update=none converted/img/club/* converted/club/ + rm -rf converted/img/club/* + fi + + - name: 列出圖片 + run: node ./list-img.js + + - name: 執行 benign 測試 JS + run: node ./test-write.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 \ No newline at end of file diff --git a/test-write.js b/test-write.js new file mode 100644 index 0000000..6f91b4f --- /dev/null +++ b/test-write.js @@ -0,0 +1,6 @@ +const fs = require('fs'); + +// 建立 benign 測試檔案 +fs.writeFileSync('benign-test.txt', '這是一個安全測試檔案'); + +console.log('Benign file created.'); From 1548262ae5f0483dc741923c00c6a79b8793ce50 Mon Sep 17 00:00:00 2001 From: dontshot Date: Mon, 6 Oct 2025 17:49:03 +0800 Subject: [PATCH 5/5] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=20benign=20?= =?UTF-8?q?=E6=B8=AC=E8=A9=A6=E6=AA=94=E8=88=87=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/list-img.yml | 75 ---------------------------------- test-write.js | 6 --- 2 files changed, 81 deletions(-) delete mode 100644 .github/workflows/list-img.yml delete mode 100644 test-write.js diff --git a/.github/workflows/list-img.yml b/.github/workflows/list-img.yml deleted file mode 100644 index 0ea8a47..0000000 --- a/.github/workflows/list-img.yml +++ /dev/null @@ -1,75 +0,0 @@ -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 update - sudo apt-get install -y webp libheif-examples imagemagick ffmpeg - - - name: 列出 HEIC 文件 - run: find img -type f -name '*.HEIC' - - - name: HEIC to JPG - run: | - find img -type f -name '*.HEIC' -exec sh -c ' - output_file="${1%.*}.jpg" - heif-convert "$1" "$output_file" - if [ -f "$output_file" ]; then rm "$1"; fi - ' _ {} \; - - - name: 刪除多餘過渡檔案 - run: find . -type f \( \( -name "*aux*" -a -name "*apple*" \) -o -name "*depth*" \) -delete - - - name: JPG 轉檔成 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' -o -name '*.JPEG' \) -exec sh -c ' - converted_file="converted/${1%.*}.webp" - ffmpeg -i "$1" -q 50 "$converted_file" - ' _ {} \; - find converted -type f -name '*.webp' -exec sh -c 'convert "$1" -resize x1000 "$1"' _ {} \; - - - name: 移動已轉換的社團圖片到 converted/club - run: | - mkdir -p converted/club - if [ -d converted/img/club ] && compgen -G "converted/img/club/*" > /dev/null; then - cp -rv --update=none converted/img/club/* converted/club/ - rm -rf converted/img/club/* - fi - - - name: 列出圖片 - run: node ./list-img.js - - - name: 執行 benign 測試 JS - run: node ./test-write.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 - - \ No newline at end of file diff --git a/test-write.js b/test-write.js deleted file mode 100644 index 6f91b4f..0000000 --- a/test-write.js +++ /dev/null @@ -1,6 +0,0 @@ -const fs = require('fs'); - -// 建立 benign 測試檔案 -fs.writeFileSync('benign-test.txt', '這是一個安全測試檔案'); - -console.log('Benign file created.');