Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Cleanup and Push Icons & JSON to Root #9

Cleanup and Push Icons & JSON to Root

Cleanup and Push Icons & JSON to Root #9

Workflow file for this run

name: Cleanup and Push Icons & JSON to Root
on:
push:
branches:
- main
paths:
- 'icons/**'
- 'json/**'
workflow_dispatch:
jobs:
clean_and_move_images:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.modified, 'icons') }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Switch to "Images" branch and hard reset to main
run: |
git fetch origin Images
git checkout Images
git reset --hard origin/main
- name: Delete everything except /icons/
run: |
find . -mindepth 1 -maxdepth 1 ! -name "icons" ! -name ".git" -exec rm -rf {} +
- name: Move icons to root
run: |
mv icons/* .
rmdir icons
- name: Commit changes to Images branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Moved icons to root and cleaned Images branch" || echo "No changes to commit"
- name: Push changes to Images branch
run: |
git push origin Images --force
clean_and_move_json:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.modified, 'json') }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Switch to "JSON" branch and hard reset to main
run: |
git fetch origin JSON
git checkout JSON
git reset --hard origin/main
- name: Delete everything except /json/
run: |
find . -mindepth 1 -maxdepth 1 ! -name "json" ! -name ".git" -exec rm -rf {} +
- name: Move json to root
run: |
mv json/* .
rmdir json
- name: Update all JSON files to change image paths
run: |
# Loop through the JSON files and replace the paths
for file in *.json; do
echo "Processing $file"
# Replace "/icons/" with "/media/icons/"
sed -i 's|"/icons/|"/media/icons/|g' "$file"
done
- name: Commit changes to JSON branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Updated image paths" || echo "No changes to commit"
- name: Push changes to JSON branch
run: |
git push origin JSON --force