From 2160753bf133647b3968e4f7a57977c589b30c27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9lio=20J=C3=BAnior?= <76992016+lunatic-fox@users.noreply.github.com> Date: Sun, 26 Feb 2023 01:55:49 -0300 Subject: [PATCH] add feature: svgo auto optimization to pull requests (#1554) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add a workflow to SVGO Optimizer * update `svgo.config.js` * Update optimize_icons.yml --------- Co-authored-by: Jørgen Kalsnes Hagen <43886029+Snailedlt@users.noreply.github.com> Co-authored-by: David Leal --- .github/scripts/svgo.config.js | 31 ++++++++++++++++++++++++++++ .github/workflows/optimize_icons.yml | 21 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .github/scripts/svgo.config.js create mode 100644 .github/workflows/optimize_icons.yml diff --git a/.github/scripts/svgo.config.js b/.github/scripts/svgo.config.js new file mode 100644 index 00000000..06ae8b74 --- /dev/null +++ b/.github/scripts/svgo.config.js @@ -0,0 +1,31 @@ +module.exports = { + plugins: [ + { + name: 'preset-default' + }, + { + name: 'removeDimensions', + params: { + overrides: { + removeDimensions: true, + } + } + }, + { + name: 'removeScriptElement', + params: { + overrides: { + removeScriptElement: true, + } + } + }, + { + name: "removeAttrs", + params: { + attrs: [ + 'path:fill:none' + ] + } + } + ] +}; diff --git a/.github/workflows/optimize_icons.yml b/.github/workflows/optimize_icons.yml new file mode 100644 index 00000000..1c2b1204 --- /dev/null +++ b/.github/workflows/optimize_icons.yml @@ -0,0 +1,21 @@ +name: Optimize icons +on: + - pull_request +permissions: write-all + +jobs: + optimize: + runs-on: ubuntu-latest + name: Optimize icons with SVGO + steps: + - uses: actions/checkout@v3 + + - uses: ericcornelissen/svgo-action@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + svgo-config: ./.github/scripts/svgo.config.js + svgo-version: 3 + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Icons optimized by SVGO