bot runner fixes #4
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: PR Assistant | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, closed] | |
| push: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| checks: write | |
| issues: write | |
| jobs: | |
| pr-validation: | |
| if: github.event_name == 'pull_request' && github.event.action != 'closed' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12' | |
| - name: Install Dependencies | |
| run: | | |
| pip install PyGithub requests pyyaml | |
| - name: Validate Bot Scripts | |
| run: | | |
| python -m py_compile bot.py workflow_manager.py comment_handler.py | |
| - name: Validate Action YAML | |
| run: | | |
| python << 'EOF' | |
| import yaml | |
| import sys | |
| try: | |
| with open('action.yml') as f: | |
| yaml.safe_load(f) | |
| print("✅ action.yml is valid") | |
| except Exception as e: | |
| print(f"❌ action.yml validation failed: {e}") | |
| sys.exit(1) | |
| EOF | |
| - name: Feedback Comment | |
| if: always() | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const outcome = '${{ job.status }}'; | |
| if (outcome === 'failure') { | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: "❌ **PR Validation Failed**\n\nPlease check the validation errors above." | |
| }); | |
| } else if (outcome === 'success') { | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: "✅ **PR Validation Passed**\n\nAll checks passed successfully!" | |
| }); | |
| } | |
| thank-you: | |
| if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| const author = context.payload.pull_request.user.login; | |
| const admins = ['FaserF', 'fabia', 'github-actions[bot]']; | |
| if (admins.includes(author)) return; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `🎉 **Thank you @${author}!**\n\nYour contribution to the **faneX-ID GitHub Bot** repository is valuable! 🚀` | |
| }); |