Skip to content

Build Registry

Build Registry #5

Workflow file for this run

name: Build Registry
on:
push:
branches:
- main
schedule:
# Every Sunday at 05:30 UTC
- cron: "30 5 * * SUN"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- name: 🛒 Checkout registry branch
uses: actions/checkout@v4
with:
repository: AvinashReddy3108/CodemosModern-Themes-Registry
ref: registry
path: registry
- name: 🛒 Checkout registrar branch
uses: actions/checkout@v4
with:
repository: AvinashReddy3108/CodemosModern-Themes-Registry
ref: registrar
path: registrar
- name: 🐍 Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- name: 📦 Install uv
run: pip install uv
- name: 📦 Install dependencies with uv
run: |
cd registrar
uv sync
- name: 🔖 Get latest Mihomo (stable) version
id: mihomo-version
run: |
echo "stable=$(curl -sL "https://api.github.com/repos/MetaCubeX/mihomo/releases/latest" | jq -r '.tag_name')" >> $GITHUB_OUTPUT
shell: bash
- name: 🍱 Restore Mihomo Installer from Cache
id: cache-mihomo-restore
uses: actions/cache/restore@v4
with:
path: mihomo-linux-amd64-${{ steps.mihomo-version.outputs.stable }}.deb
key: mihomo-linux-amd64-${{ steps.mihomo-version.outputs.stable }}
- name: 🤿 Setup and start Mihomo
run: |
[ ! -f "mihomo-linux-amd64-${{ steps.mihomo-version.outputs.stable }}.deb" ] && curl -fsSL "https://github.com/MetaCubeX/mihomo/releases/download/${{ steps.mihomo-version.outputs.stable }}/mihomo-linux-amd64-${{ steps.mihomo-version.outputs.stable }}.deb" -o "mihomo-linux-amd64-${{ steps.mihomo-version.outputs.stable }}.deb"
sudo dpkg -i ./mihomo-linux-amd64-${{ steps.mihomo-version.outputs.stable }}.deb
uv run registrar/mihomo_daemon.py
shell: bash
- name: 🕸️ Run registrar
run: |
cd registrar
export ALL_PROXY="http://localhost:7890"
DISABLE_CACHE=true uv run registrar --concurrency 25
shell: bash
- name: ✅ Validate index.json
id: version
run: |
cd registry
VERSION=$(jq -r '.version' index.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
[ -s "index.json" ] && echo "🎉 index.json generated successfully!" || exit 1
shell: bash
- name: ✏️ Commit and push changes
run: |
cd registry
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add index.json registry/*
git commit -m "chore: update index to ${{ steps.version.outputs.version }}" || echo "No changes to commit!"
git push origin registry
- name: 🚮 Delete older releases
uses: dev-drprasad/delete-older-releases@v0.3.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
keep_latest: 3
delete_tags: true
- name: 🚀 Upload new release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
body: "Automated weekly update!"
files: |
registry/index.json