Skip to content

Refactor project config and refresh UI tooling #57

Refactor project config and refresh UI tooling

Refactor project config and refresh UI tooling #57

Workflow file for this run

name: Agent PR
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
issue_comment:
types: [created]
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: agent-pr-${{ github.event.pull_request.number || github.event.issue.number }}
cancel-in-progress: false
env:
CODEX_REVIEW_MODEL: ${{ vars.CODEX_REVIEW_MODEL || 'gpt-5.4-mini' }}
CODEX_RESOLVE_MODEL: ${{ vars.CODEX_RESOLVE_MODEL || 'gpt-5.4' }}
CODEX_DISCUSS_MODEL: ${{ vars.CODEX_DISCUSS_MODEL || 'gpt-5.4-mini' }}
jobs:
review-agent:
name: Codex Review Agent
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Fetch base branch
run: git fetch origin "${{ github.event.pull_request.base.ref }}"
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g @openai/codex
- name: Run Codex review
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
set -euo pipefail
if [ -z "${OPENAI_API_KEY:-}" ]; then
printf '%s\n' 'Codex review skipped because the `OPENAI_API_KEY` Actions secret is not configured.' > "$RUNNER_TEMP/codex-review.md"
exit 0
fi
codex review \
--base "origin/${{ github.event.pull_request.base.ref }}" \
--model "$CODEX_REVIEW_MODEL" \
"Review this pull request for correctness, regressions, missing tests, security issues, release risk, and documentation drift. Prioritize actionable findings with file paths and line references. Keep the output concise and do not include praise." \
> "$RUNNER_TEMP/codex-review.md"
- name: Post review comment
env:
GH_TOKEN: ${{ github.token }}
run: gh pr comment "${{ github.event.pull_request.number }}" --body-file "$RUNNER_TEMP/codex-review.md"
resolver-agent:
name: Codex Resolver Agent
runs-on: ubuntu-latest
needs: review-agent
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.actor != 'github-actions[bot]'
permissions:
contents: write
pull-requests: write
issues: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
token: ${{ github.token }}
- name: Fetch base branch
run: git fetch origin "${{ github.event.pull_request.base.ref }}"
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy, rustfmt
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g @openai/codex
- name: Resolve review findings
env:
GH_TOKEN: ${{ github.token }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
if [ -z "${OPENAI_API_KEY:-}" ]; then
gh pr comment "$PR_NUMBER" --body "Codex resolver skipped because the \`OPENAI_API_KEY\` Actions secret is not configured."
exit 0
fi
gh pr view "$PR_NUMBER" --comments > "$RUNNER_TEMP/pr-context.txt"
codex exec \
--model "$CODEX_RESOLVE_MODEL" \
--sandbox workspace-write \
--ask-for-approval never \
"Address actionable review comments and obvious CI failures for PR #${PR_NUMBER}. Make minimal changes, keep public behavior stable unless the PR intends otherwise, run focused validation where practical, and leave unrelated code untouched. PR context is in $RUNNER_TEMP/pr-context.txt."
if git diff --quiet; then
gh pr comment "$PR_NUMBER" --body "Codex resolver found no safe code changes to apply."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Fix: address agent review findings"
git push origin "HEAD:${{ github.event.pull_request.head.ref }}"
gh pr comment "$PR_NUMBER" --body "Codex resolver pushed fixes to this PR branch."
discussion-agent:
name: Codex Discussion Agent
runs-on: ubuntu-latest
if: >
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
startsWith(github.event.comment.body, '/agent-discuss')
steps:
- name: Resolve PR metadata
id: pr
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh pr view "${{ github.event.issue.number }}" --json headRefName,baseRefName > pr.json
echo "head_ref=$(jq -r '.headRefName' pr.json)" >> "$GITHUB_OUTPUT"
echo "base_ref=$(jq -r '.baseRefName' pr.json)" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.base_ref }}
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- run: npm install -g @openai/codex
- name: Discuss PR
env:
GH_TOKEN: ${{ github.token }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PR_NUMBER: ${{ github.event.issue.number }}
COMMENT_BODY: ${{ github.event.comment.body }}
run: |
set -euo pipefail
if [ -z "${OPENAI_API_KEY:-}" ]; then
gh pr comment "$PR_NUMBER" --body "Codex discussion skipped because the \`OPENAI_API_KEY\` Actions secret is not configured."
exit 0
fi
gh pr view "$PR_NUMBER" --comments --json title,body,comments,files > "$RUNNER_TEMP/pr-context.json"
printf '%s\n' "$COMMENT_BODY" > "$RUNNER_TEMP/agent-question.txt"
codex exec \
--model "$CODEX_DISCUSS_MODEL" \
--sandbox read-only \
--ask-for-approval never \
--output-last-message "$RUNNER_TEMP/agent-discussion.md" \
"Answer the PR discussion request in $RUNNER_TEMP/agent-question.txt using the PR context in $RUNNER_TEMP/pr-context.json and the repository. Be concrete, cite files where useful, and do not modify files."
gh pr comment "$PR_NUMBER" --body-file "$RUNNER_TEMP/agent-discussion.md"