Optimize SVG files #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: optimize-svg | |
on: | |
push: | |
branches: | |
- main | |
# Allows you to run this workflow manually | |
workflow_dispatch: | |
jobs: | |
optimize: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref || 'main' }} | |
# This action secret contains a fine-grained personal access token with permissions to read/write repo content | |
# It is necessary because the default GITHUB_TOKEN cannot re-trigger workflows after pushing | |
token: ${{ secrets.COMBINE_CI_TOKEN || secrets.GITHUB_TOKEN }} | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
**/node_modules | |
.yarn/cache | |
key: ${{ runner.os }}-yarn-cache-${{ hashFiles('./yarn.lock') }} | |
- name: yarn-install | |
run: | | |
yarn install | |
CHANGES=$(git status -s) | |
if [[ ! -z $CHANGES ]]; then | |
echo "Changes found: $CHANGES" | |
git diff | |
exit 1 | |
fi | |
- name: setup-node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: optimize-svgs | |
run: | | |
node ./scripts/optimize-svg.js | |
- name: configure-git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: commit-changes | |
run: | | |
CHANGES=$(git status -s) | |
if [[ ! -z $CHANGES ]]; then | |
git add . | |
git commit -m "Optimize SVG files" | |
git push | |
else | |
echo "No changes to commit." | |
fi |