name: agent-issue-to-pr on: issues: types: [labeled] jobs: agent: if: github.event.label.name == 'agent:do' runs-on: docker container: python:3.12 steps: - uses: actions/checkout@v4 - name: Install Aider run: pip install --upgrade pip aider-chat - name: Create branch id: mkbr run: | BR="agent/${{ github.event.issue.number }}" echo "BR=$BR" >> $GITHUB_ENV git checkout -b "$BR" git config user.name "forgejo-actions[bot]" git config user.email "actions@forgejo.local" - name: Run agent (write code + tests) env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} run: | aider --yes --message "Issue #${{ github.event.issue.number }} — ${{ github.event.issue.title }}. Сделай минимальный патч и тесты. CI не трогай." . git add -A git commit -m "agent: implement #${{ github.event.issue.number }}" || true git push -u origin "$BR" - name: Open PR via API env: API: ${{ github.api_url }} REPO: ${{ github.repository }} TOKEN: ${{ github.token }} run: | curl -sS -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \ -d '{"head":"'"$BR"'","base":"main","title":"Agent PR for #'"${{ github.event.issue.number }}"'","body":"Автогенерация по issue."}' \ "$API/repos/$REPO/pulls"