-
Notifications
You must be signed in to change notification settings - Fork 2
[PAT-5148] extend to have option for codex action #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
b52ccf2
3b1cc38
dbcd47f
d31dbba
c739f57
1a270e8
fb2e064
58ad09f
a521112
4e3e44a
431429c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,15 +48,48 @@ on: | |
| description: "LLM model to use for general purpose tasks" | ||
| required: false | ||
| type: string | ||
| codex_model: | ||
| description: "OpenAI model to use for Codex agent" | ||
| required: false | ||
| type: string | ||
| default: "o3" | ||
|
|
||
| jobs: | ||
| run-ci-ai-agent: | ||
| detect-agent: | ||
| if: | | ||
| inputs.event_name == 'issues' || | ||
| inputs.event_name == 'issue_comment' || | ||
| inputs.event_name == 'pull_request_review_comment' || | ||
| inputs.event_name == 'pull_request_review' | ||
| runs-on: gha-production-medium | ||
| outputs: | ||
| agent: ${{ steps.parse.outputs.agent }} | ||
| codex_prompt: ${{ steps.parse.outputs.codex_prompt }} | ||
| steps: | ||
| - name: Parse agent from comment | ||
| id: parse | ||
| shell: bash | ||
| env: | ||
| EVENT_PAYLOAD: ${{ inputs.event_payload }} | ||
| run: | | ||
| comment=$(echo "$EVENT_PAYLOAD" | jq -r '.comment.body // .review.body // .issue.body // ""') | ||
|
|
||
| if echo "$comment" | grep -q '/codex-'; then | ||
| echo "agent=codex" >> $GITHUB_OUTPUT | ||
| # Extract the command after /codex- (e.g., "review-pr" from "/codex-review-pr") | ||
| codex_cmd=$(echo "$comment" | grep -oE '/codex-[^ ]+' | head -1 | sed 's|/codex-||') | ||
|
||
| # Extract any additional context after the command on the same line or following lines | ||
| full_prompt=$(echo "$comment" | sed -n '/\/codex-/,$p' | sed '1s|.*/codex-[^ ]*||') | ||
|
||
| echo "codex_prompt=${codex_cmd}${full_prompt}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "agent=claude" >> $GITHUB_OUTPUT | ||
| echo "codex_prompt=" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| run-claude-agent: | ||
| needs: detect-agent | ||
| if: needs.detect-agent.outputs.agent == 'claude' | ||
| runs-on: gha-production-medium | ||
| container: ci-images-release.arti.tw.ee/actions_java_17_and_21 | ||
| permissions: | ||
| contents: write | ||
|
|
@@ -107,4 +140,53 @@ jobs: | |
| ${{ secrets.ANTHROPIC_BEDROCK_BASE_URL }} | ||
| claude_args: | | ||
| --allowedTools "mcp__github_inline_comment__create_inline_comment,mcp__github_file_ops__commit_files,mcp__github_file_ops__delete_files" | ||
| --model ${{ inputs.generic_model != '' && inputs.generic_model || vars.ANTHROPIC_DEFAULT_HAIKU_MODEL }} | ||
| --model ${{ inputs.generic_model != '' && inputs.generic_model || vars.ANTHROPIC_DEFAULT_HAIKU_MODEL }} | ||
|
|
||
| run-codex-agent: | ||
| needs: detect-agent | ||
| if: needs.detect-agent.outputs.agent == 'codex' | ||
| runs-on: gha-production-medium | ||
| # container: ci-images-release.arti.tw.ee/actions_java_17_and_21 | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| issues: write | ||
| id-token: write | ||
| actions: read | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| fetch-depth: 1 | ||
|
|
||
| - name: "Add repo as safe directory" | ||
| run: | | ||
| git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
|
|
||
| - name: Sync caller event context | ||
| shell: bash | ||
| env: | ||
| CALLER_EVENT_PAYLOAD: ${{ inputs.event_payload }} | ||
| run: | | ||
| event_file="$RUNNER_TEMP/original_event.json" | ||
| printf '%s' "$CALLER_EVENT_PAYLOAD" > "$event_file" | ||
| { | ||
| echo "GITHUB_EVENT_PATH=$event_file" | ||
| echo "GITHUB_EVENT_NAME=${{ inputs.event_name }}" | ||
| echo "GITHUB_REPOSITORY=${{ inputs.repository }}" | ||
| echo "GITHUB_REF=${{ inputs.ref }}" | ||
| echo "GITHUB_SHA=${{ inputs.sha }}" | ||
| echo "GITHUB_ACTOR=${{ inputs.actor }}" | ||
| } >> "$GITHUB_ENV" | ||
|
|
||
| - name: Run Codex Agent | ||
| uses: transferwise/[email protected] | ||
| env: | ||
| GITHUB_API_URL: https://eu.api.openai.com | ||
| with: | ||
| prompt: ${{ needs.detect-agent.outputs.codex_prompt }} | ||
| openai-api-key: ${{ secrets.OPENAI_API_KEY }} | ||
| model: ${{ inputs.codex_model }} | ||
| sandbox: "workspace-write" | ||
| allow-users: "*" | ||
| safety-strategy: "unsafe" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jq expression '.comment.body // .review.body // .issue.body' may not extract the correct content for all event types. For issue_comment events on pull requests, the comment body is correct, but for issues events, you should check both issue.body and issue.title (as done in the trigger condition on line 19). The current implementation doesn't check issue.title, which means /codex- commands in issue titles won't be detected by this parsing logic.