|
| 1 | +name: Agent |
| 2 | + |
| 3 | +on: |
| 4 | + issues: |
| 5 | + types: [labeled] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + pull-requests: write |
| 10 | + issues: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + run-agent: |
| 14 | + # Only run when the "agent/fix" label is added |
| 15 | + if: github.event.label.name == 'agent/fix' |
| 16 | + runs-on: ubuntu-24.04 |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v5 |
| 20 | + |
| 21 | + - name: Set up Docker Buildx |
| 22 | + uses: docker/setup-buildx-action@v3 |
| 23 | + |
| 24 | + - name: Configure Git |
| 25 | + run: | |
| 26 | + git config user.name "github-actions[bot]" |
| 27 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 28 | +
|
| 29 | + - name: Create branch |
| 30 | + run: | |
| 31 | + git checkout -b agent/issue-${{ github.event.issue.number }} |
| 32 | +
|
| 33 | + - name: Run agent |
| 34 | + uses: docker/cagent-action@v1 |
| 35 | + with: |
| 36 | + agent: ./agent.yml |
| 37 | + yolo: true |
| 38 | + prompt: | |
| 39 | + Work on GitHub issue: ${{ github.event.issue.html_url }} |
| 40 | +
|
| 41 | + Fetch the issue, analyze what documentation changes are needed, and implement them following your standard workflow. |
| 42 | +
|
| 43 | + If you identify any upstream coordination issues (broken links from vendored content, missing CLI flags, etc.), document them in .upstream-issues.md as specified in your instructions. |
| 44 | + env: |
| 45 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + |
| 48 | + - name: Check for changes |
| 49 | + id: changes |
| 50 | + run: | |
| 51 | + if [[ -n $(git status --porcelain) ]]; then |
| 52 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 53 | + else |
| 54 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Commit changes |
| 58 | + if: steps.changes.outputs.has_changes == 'true' |
| 59 | + run: | |
| 60 | + git add . |
| 61 | + git commit -m "docs: address issue #${{ github.event.issue.number }} |
| 62 | +
|
| 63 | + This change was automatically generated by the documentation agent team |
| 64 | + in response to issue #${{ github.event.issue.number }}. |
| 65 | +
|
| 66 | + 🤖 Generated with cagent" |
| 67 | +
|
| 68 | + - name: Push changes |
| 69 | + if: steps.changes.outputs.has_changes == 'true' |
| 70 | + run: | |
| 71 | + git push -u origin agent/issue-${{ github.event.issue.number }} |
| 72 | +
|
| 73 | + - name: Create pull request |
| 74 | + if: steps.changes.outputs.has_changes == 'true' |
| 75 | + env: |
| 76 | + GH_TOKEN: ${{ github.token }} |
| 77 | + PR_BODY: | |
| 78 | + ## Summary |
| 79 | +
|
| 80 | + This PR addresses #${{ github.event.issue.number }}. |
| 81 | +
|
| 82 | + ## Changes |
| 83 | +
|
| 84 | + The documentation agent team analyzed the issue and implemented the requested changes. |
| 85 | +
|
| 86 | + 🤖 Generated with [cagent](https://github.com/docker/cagent) |
| 87 | +
|
| 88 | + Closes #${{ github.event.issue.number }} |
| 89 | + run: | |
| 90 | + # Add upstream coordination section if file exists |
| 91 | + if [[ -f .upstream-issues.md ]]; then |
| 92 | + UPSTREAM_SECTION=$(cat .upstream-issues.md) |
| 93 | + FULL_PR_BODY="${PR_BODY/Closes #/$UPSTREAM_SECTION\n\nCloses #}" |
| 94 | + else |
| 95 | + FULL_PR_BODY="$PR_BODY" |
| 96 | + fi |
| 97 | +
|
| 98 | + gh pr create \ |
| 99 | + --title "docs: address issue #${{ github.event.issue.number }}" \ |
| 100 | + --body "$FULL_PR_BODY" \ |
| 101 | + --base main \ |
| 102 | + --head agent/issue-${{ github.event.issue.number }} |
| 103 | +
|
| 104 | + - name: Comment on issue (success) |
| 105 | + if: steps.changes.outputs.has_changes == 'true' |
| 106 | + env: |
| 107 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + run: | |
| 109 | + gh issue comment ${{ github.event.issue.number }} --body "✅ The agent team has created a PR to address this issue. Please review when ready." |
| 110 | +
|
| 111 | + - name: Comment on issue (no changes) |
| 112 | + if: steps.changes.outputs.has_changes == 'false' |
| 113 | + env: |
| 114 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 115 | + run: | |
| 116 | + gh issue comment ${{ github.event.issue.number }} --body "ℹ️ The agent team ran but didn't make any changes. This might indicate the issue needs clarification or is already resolved." |
| 117 | +
|
| 118 | + - name: Comment on issue (failure) |
| 119 | + if: failure() |
| 120 | + env: |
| 121 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + run: | |
| 123 | + gh issue comment ${{ github.event.issue.number }} --body "❌ The agent team encountered an error. Please check the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details." |
0 commit comments