From c54c15e544a71543f77ec4aaea7aa3a4bdf2b3c0 Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Mon, 31 Aug 2026 09:41:52 +0800 Subject: [PATCH 1/4] + Add workflow to optimize PNG & SVG files --- .github/workflows/compress-images.yml | 74 ++++++++++++++++++ _icons/iconColor.png | Bin 2013 -> 1992 bytes src/renderer/assets/img/defaultBanner.png | Bin 2951 -> 2930 bytes src/renderer/assets/img/yt_logo_mono_dark.png | Bin 3802 -> 3781 bytes 4 files changed, 74 insertions(+) create mode 100644 .github/workflows/compress-images.yml diff --git a/.github/workflows/compress-images.yml b/.github/workflows/compress-images.yml new file mode 100644 index 0000000000000..4873ca9674061 --- /dev/null +++ b/.github/workflows/compress-images.yml @@ -0,0 +1,74 @@ +# Compress images on demand (workflow_dispatch), and at 12am every Sunday (schedule). +# Open a Pull Request if any images can be compressed. +name: Compress Images +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' + +permissions: {} + +jobs: + compress: + # As this action runs on a schedule, only run it in the FreeTubeApp/FreeTube repository to avoid unnecessary GitHub Actions usage/billing in forks. + # Still allow the workflow to be manually triggered. + # If a fork does need this workflow, they can change this condition in their fork to include their repository. + if: github.repository == 'FreeTubeApp/FreeTube' || github.event_name == 'workflow_dispatch' + + name: Compress + runs-on: ubuntu-latest + + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout Repo + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 + + - name: Install Oxipng + run: cargo install oxipng + shell: bash + + - name: Use Node.js 24.x + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 24.x + package-manager-cache: false + + - name: Install pnpm + uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 + with: + version: 10 + cache: false + + - name: Compress SVG Images + run: pnpm dlx svgo -r -f . -o . + shell: bash + + - name: Compress PNG Images + run: oxipng -o max --strip safe --recursive ./_icons ./src + shell: bash + + - name: Generate File Diff Content + id: file_diff + uses: PikachuEXE/file-size-diff@c623d1e49f0b19ecb006caf05522f9756561052b + with: + target_branch: ${{ github.event.repository.default_branch }} + dir_glob: "**/*.png,**/*.svg" + + - name: Create New Pull Request If Needed + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + title: Compressed Images Nightly + branch-suffix: timestamp + commit-message: Compress Images + body: | + Images automagically compressed by tools in `.github/workflows/compress-images.yml` + + ${{ steps.file_diff.outputs.file_size_diff_content_markdown }} diff --git a/_icons/iconColor.png b/_icons/iconColor.png index 8ca90b629d9bafa2d5d0b4b3764ac615a150b8d4..0efaa073329adca13356ebd4db191a6c5012b49b 100644 GIT binary patch delta 10 Rcmcc1e}aF4%0|m2>;M?91PuTH delta 29 icmX@Xf0uuPiV$akM`SSr1Gg{;GcwGYBe79&IXeJyR0kpe diff --git a/src/renderer/assets/img/defaultBanner.png b/src/renderer/assets/img/defaultBanner.png index 4986e9b1a07778ef0153a00bc34708268ee046d5..42d0a7664b0c3154e80e9c8aa594231fb02c79ae 100644 GIT binary patch delta 10 RcmZn{|0Fg+Wuv7ZHvkrM1D*f? delta 29 icmew))-FClMToP&BeIx*fm;}a85w5Hk=Uph$PEB)@CLI0 diff --git a/src/renderer/assets/img/yt_logo_mono_dark.png b/src/renderer/assets/img/yt_logo_mono_dark.png index 2b4932b0b567f224e298b9f2ded8cb274ced03be..14414db3da8803d0773b6414b8174c9f27d5f3b7 100644 GIT binary patch delta 10 Rcmca5dsKFU%0|nDd;l3)1SbFh delta 29 icmX>qdrNkLiV$akM`SSrgSa3FGoDiWY`;-)2_FD^ng}ES From 3bf40001a7101c58b00f6b00f81685ca41eea8ea Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 10 Sep 2026 08:12:41 +0800 Subject: [PATCH 2/4] * Compress known folders only --- .github/workflows/compress-images.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compress-images.yml b/.github/workflows/compress-images.yml index 4873ca9674061..cd1ed71c62bc2 100644 --- a/.github/workflows/compress-images.yml +++ b/.github/workflows/compress-images.yml @@ -48,11 +48,12 @@ jobs: cache: false - name: Compress SVG Images - run: pnpm dlx svgo -r -f . -o . + run: | + pnpm dlx svgo -f ./_icons -o ./_icons + pnpm dlx svgo -f ./src/renderer/assets/img -o ./src/renderer/assets/img shell: bash - - name: Compress PNG Images - run: oxipng -o max --strip safe --recursive ./_icons ./src + run: oxipng -o max --strip safe --recursive ./_icons ./src/renderer/assets/img shell: bash - name: Generate File Diff Content From d76cd8cb84cf779cd1bc6b97160f67c444d27f5c Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 10 Sep 2026 08:14:07 +0800 Subject: [PATCH 3/4] * Run on push (mainly PR merge) instead of schedule --- .github/workflows/compress-images.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compress-images.yml b/.github/workflows/compress-images.yml index cd1ed71c62bc2..d06ff772b53d4 100644 --- a/.github/workflows/compress-images.yml +++ b/.github/workflows/compress-images.yml @@ -3,8 +3,11 @@ name: Compress Images on: workflow_dispatch: - schedule: - - cron: '0 0 * * 0' + push: + branches: [development] + paths: + - '_icons/**' + - 'src/renderer/assets/img/**' permissions: {} From 07298d021505b3a746720367c5ac013627143aca Mon Sep 17 00:00:00 2001 From: PikachuEXE Date: Thu, 10 Sep 2026 08:15:12 +0800 Subject: [PATCH 4/4] * Remove `if` since `schedule` is gone --- .github/workflows/compress-images.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/compress-images.yml b/.github/workflows/compress-images.yml index d06ff772b53d4..ed6a3f3da180e 100644 --- a/.github/workflows/compress-images.yml +++ b/.github/workflows/compress-images.yml @@ -13,11 +13,6 @@ permissions: {} jobs: compress: - # As this action runs on a schedule, only run it in the FreeTubeApp/FreeTube repository to avoid unnecessary GitHub Actions usage/billing in forks. - # Still allow the workflow to be manually triggered. - # If a fork does need this workflow, they can change this condition in their fork to include their repository. - if: github.repository == 'FreeTubeApp/FreeTube' || github.event_name == 'workflow_dispatch' - name: Compress runs-on: ubuntu-latest