Skip to content

Commit

Permalink
Add logo and resource file GH Action
Browse files Browse the repository at this point in the history
  • Loading branch information
OoLunar committed Jul 22, 2023
1 parent 6f15cd2 commit 30b8f32
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Regenerate Resource Files

on:
push:
paths:
- ".github/workflows/resources.yml"
- "res/**"
- "tools/generate-assets.sh"
workflow_dispatch:

jobs:
regenerate-assets:
name: Regenerate Resource Files
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Generate Assets
run: tools/generate-assets.sh
9 changes: 9 additions & 0 deletions res/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions tools/regenerate-assets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Deps
xbps-install -Syu > /dev/null
xbps-install -y ImageMagick yarn > /dev/null
yarn global add svgo > /dev/null

# Functions
regenerate()
{
echo "Generating assets for $1"

# Optimize the SVG file
svgo --multipass --quiet "$1"

# Convert to PNG
convert "$1" -size 1024x1024 "${1%.*}.png"

# Convert to ICO
# https://stackoverflow.com/a/15104985
convert "$1" -bordercolor white -border 0 \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
-delete 0 -alpha off -colors 256 "${1%.*}.ico"
}

# Iterate over each file matching the pattern "*.svg" in the "res" directory
for file in res/*.svg; do
# Execute the "regenerate" command on each file
regenerate "$file"
done

# Check if any files were modified
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add res > /dev/null
git diff-index --quiet HEAD
if [ "$?" == "1" ]; then
git commit -m "[ci-skip] Regenerate resource files." > /dev/null
git push > /dev/null
else
echo "No resource files were modified."
fi

0 comments on commit 30b8f32

Please sign in to comment.