Skip to content

Sync Upstream Icons

Sync Upstream Icons #4

Workflow file for this run

name: Sync Upstream Icons
on:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout your forked repository
- name: Checkout Fork Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
# Step 2: Add and fetch upstream remote
- name: Add Upstream Remote
run: |
git remote add upstream https://github.com/tabler/tabler-icons.git
git fetch upstream
# Step 3: Check for changes in icons/filled and icons/outline
- name: Check for Changes
id: check_changes
run: |
git diff --quiet origin/main upstream/main -- icons/filled/ icons/outline/
continue-on-error: true
# Step 4: Exit if no changes
- name: Exit if No Changes
if: ${{ steps.check_changes.outcome == 'success' }}
run: |
echo "No changes detected in icons. Exiting."
exit 0
# Step 5: Sync icons folder from upstream
- name: Sync Icons Folder
if: ${{ steps.check_changes.outcome == 'failure' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
# Checkout icons/filled and icons/outline from upstream
if git checkout upstream/main -- icons/filled icons/outline; then
echo "Checked out icons/filled and icons/outline from upstream."
else
echo "Failed to check out icons. Exiting."
exit 1
fi
# Add changes to staging
if git add icons/filled icons/outline; then
echo "Staged changes for commit."
else
echo "Failed to stage changes. Exiting."
exit 1
fi
# Commit changes if there are any
if git commit -m "Synced icons folders from upstream"; then
echo "Committed changes."
else
echo "No changes to commit."
fi
# Push changes to origin
if git push origin main; then
echo "Pushed changes to origin."
else
echo "Failed to push changes. Exiting."
exit 1
fi
# Step 6: Trigger modify-icons.yml workflow
- name: Trigger Modify Icons Workflow
if: ${{ steps.check_changes.outcome == 'failure' }}
run: |
echo "Triggering modify-icons workflow"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/modify-icons.yml/dispatches \
-d '{"ref": "main"}'