-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add workflows to optimize PNG & SVG files #9719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||||||||||||||||||||
| # 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: | ||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||
| branches: [development] | ||||||||||||||||||||||||||||||||||
| paths: | ||||||||||||||||||||||||||||||||||
| - '_icons/**' | ||||||||||||||||||||||||||||||||||
| - 'src/renderer/assets/img/**' | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| permissions: {} | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||
| compress: | ||||||||||||||||||||||||||||||||||
| name: Compress | ||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason to use
Suggested change
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| 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 -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/renderer/assets/img | ||||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+48
to
+55
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Targeted dirs directly, remove recursive option as there isnt anything below those dirs. Let me know if you would prefer to include recursive anyway
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You keep missing
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just to be clear, would you like to keep recursive option for both svgo and oxipng? |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| - 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 }} | ||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these lines feel kind of useless to me