GitHub PRs involve a lot of repetitive text work — writing descriptions, reviewing code, tagging issues, labelling PRs. AI agents can handle all of these programmatically via the Runcept API.
|------|-------|-------------|
RUNCEPT_API_KEY repo secret)``.github/workflows/ai-pr-automation.yml
yaml
name: AI PR Automation
on:
pull_request:
types: [opened, synchronize]
jobs:
ai-automation:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get diff
id: diff
run: |
DIFF=$(git diff origin/${{ github.base_ref }}...HEAD | head -c 8000)
echo "content<
echo "$DIFF" >> $GITHUB_OUTPUT
echo "DIFF_EOF" >> $GITHUB_OUTPUT
- name: Run PR description agent
id: pr_desc
env:
RUNCEPT_API_KEY: ${{ secrets.RUNCEPT_API_KEY }}
run: |
RESPONSE=$(curl -sS -X POST https://www.runcept.com/api/v1/run \
-H "Authorization: Bearer $RUNCEPT_API_KEY" \
-H "Content-Type: application/json" \
--data-raw "{\"agent\": \"pr-description\", \"input\": {\"diff\": $(echo '${{ steps.diff.outputs.content }}' | jq -Rs .)}}")
JOB_ID=$(echo $RESPONSE | jq -r '.job_id')
for i in {1..20}; do
sleep 4
RESULT=$(curl -sS "https://www.runcept.com/api/v1/jobs/$JOB_ID" \
-H "Authorization: Bearer $RUNCEPT_API_KEY")
if [ "$(echo $RESULT | jq -r '.status')" = "complete" ]; then
echo "description=$(echo $RESULT | jq -r '.output.description')" >> $GITHUB_OUTPUT
break
fi
done
- name: Post PR description
uses: actions/github-script@v7
with:
script: |
const desc = ${{ steps.pr_desc.outputs.description }}
// Update PR body
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: desc,
})
Adding Code Review
Add a second job that runs in parallel:
yaml
code-review:
runs-on: ubuntu-latest
needs: [] # run in parallel
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: AI code review
env:
RUNCEPT_API_KEY: ${{ secrets.RUNCEPT_API_KEY }}
run: |
# same pattern — agent: code-reviewer
# exit 1 if score < 70
``