Skip to content

Modify Icons

Modify Icons #7

Workflow file for this run

name: Modify Icons
on:
workflow_run:
workflows: ["Sync Upstream Icons"]
types:
- completed
workflow_dispatch:
jobs:
process:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout Fork Repo
- name: Checkout Fork Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
# Step 2: Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
# Step 3: Install oslllo-svg-fixer
- name: Install oslllo-svg-fixer
run: npm install -g oslllo-svg-fixer
# Step 4: Create necessary folders
- name: Create necessary folders
run: |
mkdir -p icons/combined
mkdir -p temp-icons
# Step 5: Move and Rename Icons
- name: Move and Rename Filled Icons
run: |
for file in icons/filled/*.svg; do
mv "$file" "icons/combined/$(basename "${file%.svg}")-filled.svg";
done
- name: Move and Rename Outline Icons
run: |
for file in icons/outline/*.svg; do
mv "$file" "temp-icons/$(basename "${file%.svg}")-outline.svg";
done
# Step 6: Run oslllo-svg-fixer
- name: Run oslllo-svg-fixer
run: oslllo-svg-fixer --source temp-icons --destination icons/combined
# Step 7: Commit and Push Changes
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add icons/combined/
git status
if git commit -m "Processed and updated SVG icons in combined folder"; then
echo "Committed changes."
git push
else
echo "No changes to commit or commit failed."
exit 1
fi
# Step 8: Zip the icons/combined folder
- name: Zip Icons
run: zip -r kustom-tabler-icons.zip icons/combined
# Step 9: Fetch Latest Tag from Upstream
- name: Fetch Latest Tag from Upstream
id: fetch_tag
run: |
LATEST_TAG=$(git ls-remote --tags https://github.com/tabler/tabler-icons.git | grep -o 'refs/tags/.*' | sed 's/refs\/tags\///' | sort -V | tail -n1)
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
# Step 10: Create or Update GitHub Release
- name: Create or Update GitHub Release
id: create_or_update_release
run: |
TAG_NAME="${{ env.LATEST_TAG }}"
RELEASE_NAME="Kustom Tabler Icons - $TAG_NAME"
API_URL="https://api.github.com/repos/${{ github.repository }}/releases"
# Check if release with tag already exists
RELEASE_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $API_URL | jq -r ".[] | select(.tag_name == \"$TAG_NAME\") | .id")
if [ -z "$RELEASE_ID" ]; then
# Create a new release if it doesn't exist
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
-d '{"tag_name": "'"$TAG_NAME"'","name": "'"$RELEASE_NAME"'","draft": false,"prerelease": false}' $API_URL
else
# Update the existing release if it does
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" \
-d '{"name": "'"$RELEASE_NAME"'"}' "$API_URL/$RELEASE_ID"
fi
# Step 11: Upload zip file to the release
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_or_update_release.outputs.upload_url }}
asset_path: ./kustom-tabler-icons.zip
asset_name: kustom-tabler-icons.zip
asset_content_type: application/zip