Auto Run Bounty Agent #386
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: Auto Run Bounty Agent | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| target_pr_count: | |
| description: 'Target PR count per run' | |
| required: false | |
| default: '10' | |
| max_parallel: | |
| description: 'Max parallel tasks' | |
| required: false | |
| default: '3' | |
| schedule: | |
| - cron: '0 */4 * * *' | |
| jobs: | |
| run-bounty-agent: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y jq | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install requests pyyaml | |
| - name: Install OpenCode CLI | |
| run: | | |
| if ! command -v opencode &> /dev/null; then | |
| echo "OpenCode CLI not found, using fallback mode" | |
| fi | |
| echo "OPENCODE_INSTALLED=$(command -v opencode &> /dev/null && echo 'true' || echo 'false')" >> $GITHUB_ENV | |
| - name: Run Bounty Agent | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_USERNAME: ${{ github.repository_owner }} | |
| TARGET_PR_COUNT: ${{ github.event.inputs.target_pr_count || '10' }} | |
| MAX_PARALLEL: ${{ github.event.inputs.max_parallel || '3' }} | |
| run: | | |
| echo "==============================================" | |
| echo "GitHub Bounty Agent - Starting..." | |
| echo "==============================================" | |
| echo "Target PR Count: $TARGET_PR_COUNT" | |
| echo "Max Parallel: $MAX_PARALLEL" | |
| echo "User: $GITHUB_USERNAME" | |
| echo "==============================================" | |
| python3 opencode_bounty_agent.py \ | |
| --target-pr-count $TARGET_PR_COUNT \ | |
| --max-parallel $MAX_PARALLEL \ | |
| --work-dir ./workspace || true | |
| echo "==============================================" | |
| echo "Bounty Agent completed" | |
| echo "==============================================" | |
| - name: Collect results | |
| if: always() | |
| run: | | |
| echo "## GitHub Bounty Agent Results" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Run Time:** $(date)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ -d "workspace/results" ]; then | |
| echo "### Results Found" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| for result_file in workspace/results/final_*.json; do | |
| if [ -f "$result_file" ]; then | |
| echo "\`\`\`json" >> $GITHUB_STEP_SUMMARY | |
| cat "$result_file" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| done | |
| else | |
| echo "### No Results Files Found" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| if [ -d "workspace" ]; then | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Workspace Contents" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| ls -la workspace/ 2>/dev/null || echo "Empty" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Upload results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bounty-results-${{ github.run_id }} | |
| path: | | |
| workspace/ | |
| retention-days: 7 | |
| - name: Create issue on failure | |
| if: failure() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const title = `Bounty Agent Run Failed - ${new Date().toISOString().split('T')[0]}`; | |
| const body = ` | |
| ## Run Details | |
| - **Run ID:** ${{ github.run_id }} | |
| - **Run Number:** ${{ github.run_number }} | |
| - **Triggered by:** ${{ github.event_name }} | |
| - **Branch:** ${{ github.ref }} | |
| ## Error | |
| The bounty agent workflow failed. Please check the logs for details. | |
| [View Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | |
| `; | |
| const issues = await github.rest.issues.listForRepo({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| state: 'open', | |
| labels: 'bounty-agent-failure' | |
| }); | |
| if (issues.data.length === 0) { | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: title, | |
| body: body, | |
| labels: ['bounty-agent-failure', 'automated'] | |
| }); | |
| } |