New logos and fixes #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: Resize SVGs | |
on: | |
push: | |
paths: | |
- "static/logos/**" | |
- ".github/scripts/resize-logos.py" | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "static/logos/**" | |
jobs: | |
resize_svgs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: Get branch name | |
uses: rlespinasse/github-slug-action@v3.x | |
- name: Install dependencies | |
run: | | |
sudo python -m pip install --upgrade pip | |
sudo pip install lxml | |
npm install -g svgo | |
- name: Checkout branch or create new one | |
run: | | |
git fetch | |
if git branch -a | grep origin/${{ env.GITHUB_HEAD_REF_SLUG }}; then | |
git checkout ${{ env.GITHUB_HEAD_REF_SLUG }} | |
else | |
git checkout -b ${{ env.GITHUB_HEAD_REF_SLUG }} | |
fi | |
- name: Resize SVGs | |
run: | | |
sudo python .github/scripts/resize-logos.py static/logos 64 | |
- name: Optimize SVGs with SVGO | |
run: | | |
svgo -f static/logos -r -o static/logos | |
- name: Check if there are changes to commit | |
id: check_changes | |
run: | | |
git add . | |
if git diff --cached --quiet; then | |
echo "No changes to commit" | |
echo "::set-output name=changed::false" | |
else | |
echo "Changes detected" | |
echo "::set-output name=changed::true" | |
fi | |
- name: Commit and push changes | |
if: steps.check_changes.outputs.changed == 'true' | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git commit -m "Resize SVGs to height 64px" | |
git push origin ${{ env.GITHUB_HEAD_REF_SLUG }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |