|
| 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: Install cagent |
| 25 | + run: | |
| 26 | + mkdir -p $HOME/bin |
| 27 | + curl -fsSL https://github.com/docker/cagent/releases/download/v1.15.5/cagent-linux-amd64 -o $HOME/bin/cagent |
| 28 | + chmod +x $HOME/bin/cagent |
| 29 | + echo "$HOME/bin" >> $GITHUB_PATH |
| 30 | +
|
| 31 | + - name: Configure Git |
| 32 | + run: | |
| 33 | + git config user.name "docker-docs-bot" |
| 34 | + git config user.email "[email protected]" |
| 35 | +
|
| 36 | + - name: Create branch |
| 37 | + run: | |
| 38 | + git checkout -b agent/issue-${{ github.event.issue.number }} |
| 39 | +
|
| 40 | + - name: Run agent |
| 41 | + env: |
| 42 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 43 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + run: | |
| 45 | + cagent exec agent.yml --yolo "Work on GitHub issue: ${{ github.event.issue.html_url }} |
| 46 | +
|
| 47 | + Fetch the issue, analyze what documentation changes are needed, and implement them following your standard workflow. |
| 48 | +
|
| 49 | + 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." |
| 50 | +
|
| 51 | + - name: Check for changes |
| 52 | + id: changes |
| 53 | + run: | |
| 54 | + if [[ -n $(git status --porcelain) ]]; then |
| 55 | + echo "has_changes=true" >> $GITHUB_OUTPUT |
| 56 | + else |
| 57 | + echo "has_changes=false" >> $GITHUB_OUTPUT |
| 58 | + fi |
| 59 | +
|
| 60 | + - name: Commit changes |
| 61 | + if: steps.changes.outputs.has_changes == 'true' |
| 62 | + run: | |
| 63 | + git add . |
| 64 | + git commit -m "docs: address issue #${{ github.event.issue.number }} |
| 65 | +
|
| 66 | + This change was automatically generated by the documentation agent team |
| 67 | + in response to issue #${{ github.event.issue.number }}. |
| 68 | +
|
| 69 | + 🤖 Generated with cagent" |
| 70 | +
|
| 71 | + - name: Push changes |
| 72 | + if: steps.changes.outputs.has_changes == 'true' |
| 73 | + run: | |
| 74 | + git push origin agent/issue-${{ github.event.issue.number }} |
| 75 | +
|
| 76 | + - name: Create pull request |
| 77 | + if: steps.changes.outputs.has_changes == 'true' |
| 78 | + env: |
| 79 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + run: | |
| 81 | + # Build PR body |
| 82 | + PR_BODY="## Summary |
| 83 | +
|
| 84 | + This PR addresses #${{ github.event.issue.number }}. |
| 85 | +
|
| 86 | + ## Changes |
| 87 | +
|
| 88 | + The documentation agent team analyzed the issue and implemented the requested changes." |
| 89 | +
|
| 90 | + # Add upstream coordination section if file exists |
| 91 | + if [[ -f .upstream-issues.md ]]; then |
| 92 | + PR_BODY="$PR_BODY |
| 93 | +
|
| 94 | + $(cat .upstream-issues.md)" |
| 95 | + fi |
| 96 | +
|
| 97 | + PR_BODY="$PR_BODY |
| 98 | +
|
| 99 | + 🤖 Generated with [cagent](https://github.com/docker/cagent) |
| 100 | +
|
| 101 | + Closes #${{ github.event.issue.number }}" |
| 102 | +
|
| 103 | + gh pr create \ |
| 104 | + --title "docs: address issue #${{ github.event.issue.number }}" \ |
| 105 | + --body "$PR_BODY" \ |
| 106 | + --head agent/issue-${{ github.event.issue.number }} \ |
| 107 | + --base main |
| 108 | +
|
| 109 | + - name: Comment on issue (success) |
| 110 | + if: steps.changes.outputs.has_changes == 'true' |
| 111 | + env: |
| 112 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 113 | + run: | |
| 114 | + gh issue comment ${{ github.event.issue.number }} --body "✅ The agent team has created a PR to address this issue. Please review when ready." |
| 115 | +
|
| 116 | + - name: Comment on issue (no changes) |
| 117 | + if: steps.changes.outputs.has_changes == 'false' |
| 118 | + env: |
| 119 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 120 | + run: | |
| 121 | + 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." |
| 122 | +
|
| 123 | + - name: Comment on issue (failure) |
| 124 | + if: failure() |
| 125 | + env: |
| 126 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 127 | + run: | |
| 128 | + 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