Modify Icons #18
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: Modify Icons | |
on: | |
workflow_dispatch: | |
jobs: | |
process: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout Fork Repo | |
- name: Checkout Fork Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# Step 2: Set up Node.js environment | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
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 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 | |
- name: Zip Icons | |
run: | | |
ZIP_FILE="$HOME/kustom-tabler-icons.zip" | |
zip -r $ZIP_FILE icons/combined | |
echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_ENV | |
# Step 9: Fetch Latest Tag from Upstream | |
- name: Fetch Latest Tag from Upstream | |
id: fetch_tag | |
run: | | |
LATEST_TAG=$(curl -s https://api.github.com/repos/tabler/tabler-icons/releases/latest | jq -r .tag_name) | |
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 | |
RESPONSE=$(curl -s -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) | |
UPLOAD_URL=$(echo "$RESPONSE" | jq -r ".upload_url" | sed 's/{?name,label}//') | |
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV | |
else | |
# Update the existing release if it does | |
RESPONSE=$(curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-d '{"name": "'"$RELEASE_NAME"'"}' \ | |
"$API_URL/$RELEASE_ID") | |
UPLOAD_URL=$(echo "$RESPONSE" | jq -r ".upload_url" | sed 's/{?name,label}//') | |
echo "UPLOAD_URL=${UPLOAD_URL}" >> $GITHUB_ENV | |
fi | |
# Step 11: Check File Existence | |
- name: Check File Existence | |
run: | | |
if [ ! -f ${{ env.ZIP_FILE }} ]; then | |
echo "File not found!" | |
exit 1 | |
fi | |
# Step 12: Upload Release Asset | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ env.UPLOAD_URL }} | |
asset_path: ${{ env.ZIP_FILE }} | |
asset_name: kustom-tabler-icons.zip | |
asset_content_type: application/zip |