Skip to content

Commit 3369079

Browse files
committed
feat(workflows): add Codex automation for issue processing
- Introduced a new GitHub Actions workflow `codex.yml` to automate issue processing using OpenAI Codex. - Configured the workflow to trigger on issue creation with titles containing `[codex]`. - Added steps to: - Install Codex CLI and process issues with custom instructions. - Create a new branch and commit changes if modifications are made. - Automatically open a pull request and comment on the issue. - Utilized GitHub Models API for Codex inference with GPT-4.1.
1 parent cd2f8df commit 3369079

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/codex.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Source: https://gist.github.com/sgoedecke/2b4e8d5e6b21f536ea399f1728916ad5
2+
name: Codex on GitHub Models
3+
4+
on:
5+
issues:
6+
types: [opened]
7+
8+
jobs:
9+
process-issue:
10+
if: contains(github.event.issue.title, '[codex]')
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
issues: write
15+
pull-requests: write
16+
models: read
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: '22'
26+
27+
- name: Install Codex CLI
28+
run: npm install -g @openai/codex
29+
30+
- name: Process issue with Codex
31+
env:
32+
OPENAI_API_KEY: ${{ secrets.GITHUB_TOKEN }}
33+
ISSUE_BODY: ${{ github.event.issue.body }}
34+
ISSUE_NUMBER: ${{ github.event.issue.number }}
35+
ISSUE_TITLE: ${{ github.event.issue.title }}
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
INSTRUCTION="$ISSUE_TITLE --- $ISSUE_BODY"
39+
40+
BRANCH_NAME="codex/issue-$ISSUE_NUMBER"
41+
git checkout -b $BRANCH_NAME
42+
43+
export OPENAI_BASE_URL=https://models.github.ai/inference
44+
45+
# any provider string would work here, it's just so codex knows it's using a custom model
46+
codex --approval-mode full-auto --provider github --model openai/gpt-4.1 "$INSTRUCTION"
47+
48+
if [[ -n $(git status --porcelain) ]]; then
49+
git config user.name "GitHub Models Codex Bot"
50+
git config user.email "github-models-codex-bot@noreply.github.com"
51+
52+
git add .
53+
git commit -m "Codex changes for issue #$ISSUE_NUMBER"
54+
git push origin $BRANCH_NAME
55+
56+
# Create PR and comment on issue using the same token
57+
gh pr create --title "Codex: ${{ github.event.issue.title }}" \
58+
--body "Auto-generated by Codex for issue #$ISSUE_NUMBER" \
59+
--base ${{ github.event.repository.default_branch }} \
60+
--head $BRANCH_NAME
61+
62+
gh issue comment $ISSUE_NUMBER --body "Codex created a PR for this issue"
63+
else
64+
gh issue comment $ISSUE_NUMBER --body "Codex processed this issue but made no changes"
65+
fi

0 commit comments

Comments
 (0)