packages-updated #29
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: Sync Registry from Packages | |
| on: | |
| repository_dispatch: | |
| types: [packages-updated] | |
| workflow_dispatch: | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Fetch Packages index and meta.json files | |
| run: | | |
| # Download APT Packages index | |
| curl -fsSL "https://cardputerzero.github.io/packages/dists/stable/main/binary-arm64/Packages" -o /tmp/Packages | |
| # Download all meta.json files by parsing package names from index | |
| mkdir -p /tmp/meta | |
| grep '^Package: ' /tmp/Packages | awk '{print $2}' | sort -u | while read pkg; do | |
| url="https://raw.githubusercontent.com/CardputerZero/packages/main/pool/main/${pkg}/meta.json" | |
| curl -fsSL "$url" -o "/tmp/meta/${pkg}.json" 2>/dev/null || true | |
| done | |
| - name: Generate registry JSON | |
| run: | | |
| python3 scripts/generate_registry.py \ | |
| --packages /tmp/Packages \ | |
| --meta-dir /tmp/meta \ | |
| --overrides registry-overrides.json \ | |
| --out generated | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| if git diff --quiet generated/; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| # The registry is derived data: packages already went through human | |
| # review in CardputerZero/packages (publish PR), so the sync commits | |
| # straight to main — a second review gate here only let the store lag. | |
| - name: Commit updated registry to main | |
| if: steps.diff.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add generated/ | |
| git commit -m "chore: sync registry from packages repository" | |
| # Rebase in case another run landed between checkout and push. | |
| git pull --rebase origin main | |
| git push origin main |