Skip to content

Icon Modifier

Icon Modifier #36

Workflow file for this run

name: Icon Modifier
permissions: write-all
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
outputs:
SYNC_TRUE: ${{ steps.need_sync.outputs.SYNC_TRUE }}
steps:
# Step 1: Checkout Repository
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
# Step 2: Sync icons folder from upstream
- name: Configure Git User Information
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Add Upstream Remote
run: git remote add upstream https://github.com/tabler/tabler-icons.git
- name: Fetch Updates from Upstream
run: git fetch upstream
- name: Checkout Icons from Upstream
run: git checkout upstream/main -- icons/filled icons/outline
- name: Check for Icon Changes
id: need_sync
continue-on-error: true
run: |
if git diff --cached --quiet; then
echo "SYNC_TRUE=0" >> $GITHUB_ENV
echo "SYNC_TRUE=0" >> $GITHUB_OUTPUT
echo "Icons are up to date."
exit 0
else
echo "SYNC_TRUE=1" >> $GITHUB_ENV
echo "SYNC_TRUE=1" >> $GITHUB_OUTPUT
echo "Icons are not up to date."
fi
- name: Create Temporary Branch
if: ${{ steps.need_sync.outputs.SYNC_TRUE == '1' }}
run: git checkout --orphan temp
- name: Stage Files
if: ${{ steps.need_sync.outputs.SYNC_TRUE == '1' }}
run: |
git add icons/filled icons/outline .github/workflows/manual.yml
- name: Commit Changes
if: ${{ steps.need_sync.outputs.SYNC_TRUE == '1' }}
run: git commit -m "Synced Icons"
- name: Replace Old Branch with New Branch
if: ${{ steps.need_sync.outputs.SYNC_TRUE == '1' }}
run: git branch -D main && git branch -M main
- name: Push Changes
if: ${{ steps.need_sync.outputs.SYNC_TRUE == '1' }}
run: git push origin main --force
process:
runs-on: ubuntu-latest
needs: sync
if: ${{ needs.sync.outputs.SYNC_TRUE == '1' }}
steps:
# Step 1
# - Checkout Fork Repo
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
# Step 2
# - Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
# Step 3
# - Install npm packages
- name: Install Tools
run: |
npm install -g oslllo-svg-fixer
npm install -g svgtofont
# Step 4
# - Create temp to work on this directory
# - Create temp/fixed to fix and store outine icons on this directory
# - Create temp/icons to store filled and fixed outline icons on this directory
- name: Create Temporary Folders
run: |
mkdir -pv temp/icons temp/fixed
# Step 5
# - Fix outline icons from "icons/outline" to "temp/fixed".
# - Move outline icons from "temp/fixed" to "temp/icons".
# - Rename & Copy filled icons from "icons/filled" to "temp/icons".
- name: Process Icons
run: |
oslllo-svg-fixer --source icons/outline --destination temp/fixed
for SVG in temp/fixed/*.svg; do
mv -f $SVG "temp/icons/$(basename "${SVG%.svg}")-outline.svg"
done
for SVG in icons/filled/*.svg; do
mv -f $SVG "temp/icons/$(basename "${SVG%.svg}")-filled.svg"
done
# Step 6
# - Convert SVGs to TTF and JSON Map
- name: Convert Icons
run: |
svgtofont --sources temp/icons --output temp --fontName tabler-icons
# Step 7
# - Get latest tag from upstream
# - Create a zip file from temp/icons
- name: Zip Icons
run: |
LATEST_TAG=$(curl -s https://api.github.com/repos/tabler/tabler-icons/releases/latest | jq -r .tag_name)
echo "TAG=${LATEST_TAG}" >> $GITHUB_ENV
zip -r temp/tabler-icons.zip temp/icons
# Step 8
# - Create or Update GitHub Release
# - Upload ZIP to GitHub Release
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
temp/tabler-icons.ttf
temp/tabler-icons.json
temp/tabler-icons.zip
name: "Kustom Tabler Icons ${{ env.TAG }}"
tag_name: ${{ env.TAG }}