Plugin Management #109
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: Plugin Management | |
| 'on': | |
| schedule: | |
| # Run daily at 2 AM UTC to check for plugin updates | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| operation: | |
| description: 'Operation to perform' | |
| required: true | |
| default: 'check-updates' | |
| type: choice | |
| options: | |
| - check-updates | |
| - list-prs | |
| - sync-submodules | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| issues: write | |
| jobs: | |
| plugin-operations: | |
| name: Plugin Operations | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository with submodules | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup GitHub CLI | |
| run: | | |
| gh auth setup-git | |
| gh auth status | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Check for plugin updates | |
| if: github.event.inputs.operation == 'check-updates' || github.event_name == 'schedule' | |
| run: | | |
| echo "Checking for plugin updates..." | |
| # List all plugin repositories | |
| PLUGINS=("entity-plugin-examples" "entity-plugin-gpt-oss" "entity-plugin-stdlib" "entity-plugin-template") | |
| for plugin in "${PLUGINS[@]}"; do | |
| echo "Checking $plugin..." | |
| # Get latest release | |
| LATEST_RELEASE=$(gh release view --repo "Ladvien/$plugin" --json tagName -q .tagName 2>/dev/null || echo "No releases") | |
| echo " Latest release: $LATEST_RELEASE" | |
| # Get latest commit | |
| LATEST_COMMIT=$(gh api "repos/Ladvien/$plugin/commits/main" --jq '.sha[0:7]' 2>/dev/null || echo "Unable to fetch") | |
| echo " Latest commit: $LATEST_COMMIT" | |
| # Check current submodule commit | |
| if [ -d "plugins/${plugin#entity-plugin-}" ]; then | |
| CURRENT_COMMIT=$(cd "plugins/${plugin#entity-plugin-}" && git rev-parse --short HEAD) | |
| echo " Current commit: $CURRENT_COMMIT" | |
| if [ "$LATEST_COMMIT" != "$CURRENT_COMMIT" ]; then | |
| echo " ⚠️ Update available for $plugin" | |
| else | |
| echo " ✅ $plugin is up to date" | |
| fi | |
| fi | |
| echo "" | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: List plugin PRs | |
| if: github.event.inputs.operation == 'list-prs' | |
| run: | | |
| echo "Listing open PRs for plugin repositories..." | |
| PLUGINS=("entity-plugin-examples" "entity-plugin-gpt-oss" "entity-plugin-stdlib" "entity-plugin-template") | |
| for plugin in "${PLUGINS[@]}"; do | |
| echo "PRs for $plugin:" | |
| gh pr list --repo "Ladvien/$plugin" --state open --limit 10 | |
| echo "" | |
| done | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Sync submodules to latest | |
| if: github.event.inputs.operation == 'sync-submodules' | |
| run: | | |
| echo "Syncing submodules to latest commits..." | |
| # Update all submodules to their latest remote commits | |
| git submodule update --remote --merge | |
| # Check if there are changes | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create a branch for the update | |
| BRANCH_NAME="update-plugin-submodules-$(date +%Y%m%d)" | |
| git checkout -b "$BRANCH_NAME" | |
| # Commit the changes | |
| git add . | |
| git commit -m "chore: Update plugin submodules to latest versions | |
| Auto-generated by GitHub Actions workflow" | |
| # Push the branch | |
| git push origin "$BRANCH_NAME" | |
| # Create a pull request | |
| gh pr create \ | |
| --title "chore: Update plugin submodules" \ | |
| --body "This PR updates the plugin submodules to their latest versions. | |
| Auto-generated by the plugin management workflow. | |
| Please review the changes and merge if all tests pass." \ | |
| --label "dependencies" \ | |
| --label "automated" | |
| echo "✅ Pull request created for submodule updates" | |
| else | |
| echo "✅ All submodules are already up to date" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Generate plugin status report | |
| if: always() | |
| run: | | |
| echo "## Plugin Status Report" > plugin-status.md | |
| echo "" >> plugin-status.md | |
| echo "Generated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> plugin-status.md | |
| echo "" >> plugin-status.md | |
| # List submodule status | |
| echo "### Submodule Status" >> plugin-status.md | |
| echo '```' >> plugin-status.md | |
| git submodule status >> plugin-status.md | |
| echo '```' >> plugin-status.md | |
| # Upload as artifact | |
| echo "Report saved to plugin-status.md" | |
| - name: Upload plugin status report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: plugin-status-report | |
| path: plugin-status.md |