forked from python-openxml/python-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
164 lines (138 loc) · 5.62 KB
/
agent-develop.yml
File metadata and controls
164 lines (138 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Developer Agent
on:
issues:
types: [labeled]
workflow_dispatch:
inputs:
issue_number:
description: "Issue number to implement"
required: true
type: string
concurrency:
group: agent-develop-${{ github.event.inputs.issue_number || github.event.issue.number || github.run_id }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
issues: write
actions: write
id-token: write
jobs:
develop:
if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'product-approved'
runs-on:
- codebuild-github-runner-python-docx-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 45
env:
ANTHROPIC_MODEL: au.anthropic.claude-opus-4-6-v1
CLAUDE_CODE_USE_BEDROCK: "1"
ISSUE_NUMBER: ${{ github.event.inputs.issue_number || github.event.issue.number }}
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
- name: Configure AWS credentials (OIDC)
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_BEDROCK }}
aws-region: ap-southeast-2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install uv
run: pip install uv
- name: Install dependencies
run: uv sync --group dev
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Fetch issue details
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh issue view "$ISSUE_NUMBER" --json title,body --jq '.title' > /tmp/issue-title.txt
gh issue view "$ISSUE_NUMBER" --json title,body --jq '.body' > /tmp/issue-body.txt
- name: Create feature branch
run: |
BRANCH="agent/issue-${ISSUE_NUMBER}"
git checkout -b "$BRANCH"
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Set up non-root user for Claude Code
run: |
useradd -m agent
chown -R agent:agent "$GITHUB_WORKSPACE"
chown -R agent:agent /tmp
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Install Claude Code
run: npm install -g @anthropic-ai/claude-code
- name: Write prompt file
run: |
ISSUE_TITLE=$(cat /tmp/issue-title.txt)
ISSUE_BODY=$(cat /tmp/issue-body.txt)
cat > /tmp/prompt.txt <<INSTRUCTIONS
You are a developer agent. Implement the feature described below.
## Instructions
1. Read CLAUDE.md if it exists for project conventions.
2. Understand the existing codebase before making changes.
3. Implement the feature with clean, production-quality code.
4. Follow existing patterns and conventions in the codebase.
5. Run tests: \`uv run pytest\`
6. Run acceptance tests: \`uv run behave --stop\`
7. If tests fail, fix the issues and re-run (up to 3 attempts).
8. Commit your changes with a descriptive message referencing issue #${ISSUE_NUMBER}.
## Issue #${ISSUE_NUMBER}: ${ISSUE_TITLE}
INSTRUCTIONS
echo "" >> /tmp/prompt.txt
echo "$ISSUE_BODY" >> /tmp/prompt.txt
- name: Implement feature with Claude Code
env:
CLAUDE_CODE_USE_BEDROCK: "1"
run: |
runuser -u agent -- bash -c 'cat /tmp/prompt.txt | claude -p \
--model au.anthropic.claude-opus-4-6-v1 \
--max-turns 200 \
--dangerously-skip-permissions'
- name: Push branch
run: |
git remote set-url origin "https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/${{ github.repository }}.git"
# Revert any workflow file changes (committed or staged) — App token can't push workflow files
git checkout origin/master -- .github/workflows/ 2>/dev/null || git checkout HEAD~1 -- .github/workflows/ 2>/dev/null || true
git diff --cached --quiet .github/workflows/ 2>/dev/null || git commit --amend --no-edit 2>/dev/null || true
git push --force origin "$BRANCH"
- name: Create Pull Request
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
ISSUE_NUMBER: ${{ github.event.inputs.issue_number || github.event.issue.number }}
run: |
ISSUE_TITLE=$(cat /tmp/issue-title.txt)
ISSUE_BODY=$(cat /tmp/issue-body.txt)
gh pr create \
--title "feat: ${ISSUE_TITLE}" \
--body "## Summary
Implements #${ISSUE_NUMBER}
This PR was automatically generated by the Developer Agent.
## Original Issue
${ISSUE_BODY}
---
Generated by Developer Agent using Claude Code" \
--head "$BRANCH" \
--base master \
--label "agent-pr"
- name: Comment on issue
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
ISSUE_NUMBER: ${{ github.event.inputs.issue_number || github.event.issue.number }}
run: |
PR_URL=$(gh pr view "$BRANCH" --json url -q .url)
gh issue comment "$ISSUE_NUMBER" \
--body "**Developer Agent** has created a PR: $PR_URL
The security and review agents will now evaluate the changes."