KernelSU-Next Sync #535
This file contains hidden or 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: KernelSU-Next Sync | |
| on: | |
| schedule: | |
| - cron: '0 */6 * * *' | |
| workflow_run: | |
| workflows: ["Sync Build Deploy"] | |
| types: | |
| - completed | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-kernelsu-next: | |
| name: Sync KernelSU-Next Modules JSON | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| github.event_name == 'schedule' || | |
| github.event.workflow_run.conclusion == 'success' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch || github.ref_name }} | |
| fetch-depth: 0 | |
| - name: Pull latest changes | |
| run: git pull origin ${{ github.event.workflow_run.head_branch || github.ref_name }} | |
| - name: Configure Git identity | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Generate KernelSU-Next modules.json | |
| run: | | |
| python3 - <<'EOF' | |
| import json, pathlib, sys | |
| from datetime import datetime, timezone | |
| SRC = pathlib.Path("json/modules.json") | |
| DEST = pathlib.Path("json/kernelsu-next/modules.json") | |
| if not SRC.exists(): | |
| print(f"::error::Source file not found: {SRC}", file=sys.stderr) | |
| sys.exit(1) | |
| with SRC.open() as f: | |
| data = json.load(f) | |
| mmrl_modules = data.get("modules", []) | |
| ksu_modules = [] | |
| for mod in mmrl_modules: | |
| repo_url = mod.get("track", {}).get("source", "") | |
| if not repo_url: | |
| print(f"::warning::Skipping '{mod.get('id')}' — no source URL.") | |
| continue | |
| entry = { | |
| "name": mod.get("name", mod.get("id")), | |
| "description": mod.get("description", ""), | |
| "author": mod.get("author", "Unknown"), | |
| "repoUrl": repo_url, | |
| "license": mod.get("license", ""), | |
| } | |
| banner = mod.get("cover") or mod.get("icon") | |
| if banner: | |
| entry["bannerUrl"] = banner | |
| ksu_modules.append(entry) | |
| DEST.parent.mkdir(parents=True, exist_ok=True) | |
| with DEST.open("w") as f: | |
| json.dump(ksu_modules, f, indent=2, ensure_ascii=False) | |
| f.write("\n") | |
| print(f"Written {len(ksu_modules)} modules to {DEST}") | |
| EOF | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| git add json/kernelsu-next/modules.json | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit and push | |
| if: steps.diff.outputs.changed == 'true' | |
| run: | | |
| TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S.%6N") | |
| git commit -m "Update by CLI (${TIMESTAMP})" | |
| git push |