mirror of
https://github.com/twitter/twemoji.git
synced 2024-06-15 03:35:16 +00:00
Add SVG optimization action
This commit is contained in:
parent
9524feeca2
commit
a75e31ed39
37
.github/workflows/optimize-svgs.yml
vendored
Normal file
37
.github/workflows/optimize-svgs.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
name: optimize-svgs
|
||||
run-name: Optimize SVG size with SVGO
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- '**.svg'
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.svg'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
run-svgo:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ericcornelissen/svgo-action@v3
|
||||
id: svgo
|
||||
with:
|
||||
repo-token: ${{secrets.GITHUB_TOKEN}}
|
||||
svgo-version: 3
|
||||
- name: Commit optimizations
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
if: ${{steps.svgo.outputs.DID_OPTIMIZE}}
|
||||
with:
|
||||
commit_message: Optimize ${{steps.svgo.outputs.OPTIMIZED_COUNT}} SVG(s)
|
||||
- name: Comment on Pull Request
|
||||
uses: thollander/actions-comment-pull-request@v1
|
||||
if: ${{steps.svgo.outputs.DID_OPTIMIZE && github.event_name == 'pull_request'}}
|
||||
with:
|
||||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||
message: Optimized ${{steps.svgo.outputs.OPTIMIZED_COUNT}} SVG(s)
|
31
svgo.config.js
Normal file
31
svgo.config.js
Normal file
@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
multipass: true,
|
||||
plugins: [
|
||||
{
|
||||
name: 'preset-default',
|
||||
params: {
|
||||
overrides: {
|
||||
convertColors: {
|
||||
shortname: false,
|
||||
},
|
||||
removeViewBox: false,
|
||||
removeUselessStrokeAndFill : {
|
||||
removeNone: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
'convertStyleToAttrs',
|
||||
'removeDimensions',
|
||||
'removeRasterImages',
|
||||
'removeScriptElement',
|
||||
'removeStyleElement',
|
||||
{
|
||||
name: 'removeAttrs',
|
||||
params: {
|
||||
attrs: 'svg:fill:none|svg:xml:space',
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user