From 513dc654b0bacbae7dbdb4bdf8ddc1146df723c2 Mon Sep 17 00:00:00 2001 From: Max Litruv Boonzaayer Date: Fri, 17 Apr 2026 02:11:28 +1000 Subject: [PATCH] Add auto-index generation and update validation --- .gitea/scripts/validate-pr.js | 6 ++++ .gitea/workflows/update-index.yml | 50 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .gitea/workflows/update-index.yml diff --git a/.gitea/scripts/validate-pr.js b/.gitea/scripts/validate-pr.js index 8bf54a9..55038f5 100644 --- a/.gitea/scripts/validate-pr.js +++ b/.gitea/scripts/validate-pr.js @@ -48,6 +48,12 @@ for (const file of changedFiles) { continue; } + // Skip index.json - it's auto-generated + if (file === 'plugins/index.json') { + console.log(`⚠️ Note: index.json is auto-generated, should not be manually edited`); + continue; + } + const pluginId = file.replace('plugins/', '').replace('.json', ''); // Check if file was added or removed diff --git a/.gitea/workflows/update-index.yml b/.gitea/workflows/update-index.yml new file mode 100644 index 0000000..0e1ed0e --- /dev/null +++ b/.gitea/workflows/update-index.yml @@ -0,0 +1,50 @@ +name: Update Plugin Index +on: + push: + branches: [ main ] + paths: + - 'plugins/*.json' + +jobs: + update-index: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate index.json + run: | + cd plugins + echo '{' > index.json + echo ' "version": "1.0.0",' >> index.json + echo ' "updatedAt": "'$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")'",' >> index.json + echo ' "plugins": [' >> index.json + + first=true + for file in *.json; do + if [ "$file" != "index.json" ]; then + plugin_id="${file%.json}" + if [ "$first" = true ]; then + echo " \"$plugin_id\"" >> index.json + first=false + else + echo ", \"$plugin_id\"" >> index.json + fi + fi + done | sed '$ s/,$//' + + echo ' ]' >> index.json + echo '}' >> index.json + + - name: Commit index.json + run: | + git config user.name "Gitea Actions" + git config user.email "actions@gitea.local" + git add plugins/index.json + if git diff --staged --quiet; then + echo "No changes to index.json" + else + git commit -m "Auto-update plugin index [skip ci]" + git push + fi