Skip to content

Build App Registry #147

Build App Registry

Build App Registry #147

name: Build App Registry
on:
schedule:
- cron: '0 */6 * * *' # Every 6 hours
workflow_dispatch: # Manual trigger
push:
branches: [main]
paths: ['build_registry.py', 'external-apps.json']
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Save old registry for diff
run: cp registry.json registry_old.json 2>/dev/null || echo '{"version":1,"apps":{}}' > registry_old.json
- name: Build registry from app repos
env:
GITHUB_TOKEN: ${{ secrets.ORG_READ_TOKEN || secrets.GITHUB_TOKEN }}
run: python3 build_registry.py
- name: Detect changes
id: diff
run: python3 diff_registry.py registry_old.json registry.json
- name: Commit and push if changed
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add registry.json README.md COMMUNITY_APPS.md
git diff --staged --quiet && echo "No changes" && exit 0
git commit -m "chore: update registry.json [automated]"
for i in 1 2 3; do
git pull --rebase origin main && git push && exit 0
echo "Push attempt $i failed, retrying..."
sleep 2
done
echo "Failed to push after 3 attempts"
exit 1
- name: Notify Discord — new apps
if: steps.diff.outputs.has_new_apps == 'true'
env:
WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
APPS_JSON: ${{ steps.diff.outputs.new_apps_json }}
run: |
# Build one embed per new app
EMBEDS=$(echo "$APPS_JSON" | jq '[.[] | {
title: ("📦 " + .name + " v" + .version),
description: .description,
url: .repo,
color: 5814783,
fields: [
{ name: "Version", value: .version, inline: true },
{ name: "Platforms", value: .platforms, inline: true },
{ name: "Category", value: (.category // "—"), inline: true }
]
}]')
PAYLOAD=$(jq -n \
--arg content "**New CrossPad app available!**" \
--argjson embeds "$EMBEDS" \
'{ content: $content, embeds: $embeds }')
curl -s -H "Content-Type: application/json" -d "$PAYLOAD" "$WEBHOOK_URL"
- name: Notify Discord — new platforms
if: steps.diff.outputs.has_new_platforms == 'true'
env:
WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
PLATFORMS_JSON: ${{ steps.diff.outputs.new_platforms_json }}
run: |
EMBEDS=$(echo "$PLATFORMS_JSON" | jq '[.[] | {
title: ("🌐 " + .name + " — new platform support"),
url: .repo,
color: 3447003,
fields: [
{ name: "Version", value: .version, inline: true },
{ name: "New", value: .gained, inline: true },
{ name: "All platforms", value: .all_platforms, inline: true }
]
}]')
PAYLOAD=$(jq -n \
--argjson embeds "$EMBEDS" \
'{ embeds: $embeds }')
curl -s -H "Content-Type: application/json" -d "$PAYLOAD" "$WEBHOOK_URL"
- name: Notify Discord — version updates (nightly only)
if: steps.diff.outputs.has_version_updates == 'true' && github.event_name == 'schedule'
env:
WEBHOOK_URL: ${{ secrets.DISCORD_RELEASE_WEBHOOK }}
UPDATES_JSON: ${{ steps.diff.outputs.version_updates_json }}
run: |
EMBEDS=$(echo "$UPDATES_JSON" | jq '[.[] | {
title: ("🔄 " + .name + " updated"),
url: .repo,
color: 16750848,
fields: [
{ name: "Previous", value: .old_version, inline: true },
{ name: "New", value: .new_version, inline: true }
]
}]')
PAYLOAD=$(jq -n \
--arg content "**App updates detected**" \
--argjson embeds "$EMBEDS" \
'{ content: $content, embeds: $embeds }')
curl -s -H "Content-Type: application/json" -d "$PAYLOAD" "$WEBHOOK_URL"