Skip to content

Commit be247d5

Browse files
Refactor to use github action
1 parent bb57c79 commit be247d5

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

authors.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,3 +505,7 @@ jhall-openai:
505505
avatar: "https://avatars.githubusercontent.com/u/198997750?v=4"
506506

507507

508+
charlie-openai:
509+
name: "Charlie Weems"
510+
website: "https://wee.ms"
511+
avatar: "https://avatars.githubusercontent.com/u/181146176?v=4"

examples/codex/Autofix-github-actions.ipynb

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"id": "e2884696",
66
"metadata": {},
77
"source": [
8-
"# Autofix CI failures on GitHub with Codex-cli\n",
8+
"# Autofix CI failures on GitHub with Codex CLI\n",
99
"\n",
1010
"## Purpose of this cookbook\n",
1111
"\n",
@@ -44,7 +44,7 @@
4444
"metadata": {},
4545
"source": [
4646
"\n",
47-
"## Step 3: Insert Codex in your CI pipeline\n",
47+
"## Step 1: Add the Github Action to your CI Pipeline\n",
4848
"\n",
4949
"The following YAML shows a GitHub action that auto triggers when CI fails, installs Codex, uses codex exec and then makes a PR on the failing branch with the fix. Replace \"CI\" with the name of the workflow you want to monitor. "
5050
]
@@ -80,14 +80,14 @@
8080
" FAILED_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}\n",
8181
" FAILED_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}\n",
8282
" steps:\n",
83-
" - name: Check prerequisites\n",
83+
" - name: Check OpenAI API Key Set\n",
8484
" run: |\n",
8585
" if [ -z \"$OPENAI_API_KEY\" ]; then\n",
8686
" echo \"OPENAI_API_KEY secret is not set. Skipping auto-fix.\" >&2\n",
8787
" exit 1\n",
8888
" fi\n",
8989
"\n",
90-
" - name: Checkout failing ref\n",
90+
" - name: Checkout Failing Ref\n",
9191
" uses: actions/checkout@v4\n",
9292
" with:\n",
9393
" ref: ${{ env.FAILED_HEAD_SHA }}\n",
@@ -103,33 +103,12 @@
103103
" run: |\n",
104104
" if [ -f package-lock.json ]; then npm ci; else npm i; fi\n",
105105
"\n",
106-
" - name: Prepare Codex prerequisites\n",
107-
" shell: bash\n",
108-
" run: |\n",
109-
" # Ensure python3 exists for Codex' login helper\n",
110-
" if ! command -v python3 >/dev/null 2>&1; then\n",
111-
" sudo apt-get update\n",
112-
" sudo apt-get install -y python3\n",
113-
" fi\n",
114-
"\n",
115-
" # Ensure Codex config dir exists and is writable\n",
116-
" mkdir -p \"$HOME/.codex\"\n",
117-
" # (Optional) pin an explicit home for Codex config/logs\n",
118-
" echo \"CODEX_HOME=$HOME/.codex\" >> $GITHUB_ENV\n",
119-
"\n",
120-
" - name: Install Codex CLI\n",
121-
" run: npm i -g @openai/codex\n",
122-
"\n",
123-
" - name: Authenticate Codex (non-interactive)\n",
124-
" env:\n",
125-
" # if you set CODEX_HOME above, export it here too\n",
126-
" CODEX_HOME: ${{ env.CODEX_HOME }}\n",
127-
" OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}\n",
128-
" run: codex login --api-key \"$OPENAI_API_KEY\"\n",
129-
"\n",
130-
" - name: Run Codex to fix CI failure\n",
131-
" run: |\n",
132-
" codex exec --full-auto --sandbox workspace-write \"You are working in a Node.js monorepo with Jest tests and GitHub Actions. Read the repository, run the test suite, identify the minimal change needed to make all tests pass, implement only that change, and stop. Do not refactor unrelated code or files. Keep changes small and surgical.\"\n",
106+
" - name: Run Codex\n",
107+
" uses: openai/codex-action@main\n",
108+
" id: codex\n",
109+
" with:\n",
110+
" openai_api_key: ${{ secrets.OPENAI_API_KEY }}\n",
111+
" prompt: \"\"You are working in a Node.js monorepo with Jest tests and GitHub Actions. Read the repository, run the test suite, identify the minimal change needed to make all tests pass, implement only that change, and stop. Do not refactor unrelated code or files. Keep changes small and surgical.\"\n",
133112
"\n",
134113
" - name: Verify tests\n",
135114
" run: npm test --silent\n",
@@ -139,7 +118,7 @@
139118
" uses: peter-evans/create-pull-request@v6\n",
140119
" with:\n",
141120
" commit-message: \"fix(ci): auto-fix failing tests via Codex\"\n",
142-
" branch: codex/auto-fix-${{ github.event.workflow_run.run_id }}\n",
121+
" branch: codex/auto-fix-${{ github.event.workflow_run.id }}\n",
143122
" base: ${{ env.FAILED_HEAD_BRANCH }}\n",
144123
" title: \"Auto-fix failing CI via Codex\"\n",
145124
" body: |\n",
@@ -157,7 +136,7 @@
157136
"id": "8148024b",
158137
"metadata": {},
159138
"source": [
160-
"## Step 4: Actions Workflow kicked off\n",
139+
"## Step 2: Actions Workflow kicked off\n",
161140
"\n",
162141
"You can navigate to the Actions tab under Repo to view the failing jobs in your Actions workflow. \n",
163142
"\n",
@@ -181,7 +160,7 @@
181160
"id": "d08a3ecc",
182161
"metadata": {},
183162
"source": [
184-
"## Step 5: Codex generated PR for review\n",
163+
"## Step 3: Verify that Codex Created a PR for Review\n",
185164
"And after the Codex workflow completes execution, it should open a pull request from the feature branch codex/auto-fix. Check to see if everything looks good and then merge it.\n",
186165
"\n",
187166
"<img src=\"../../images/codex-pr.png\" width=\"700\"/>\n",

registry.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,12 +2541,13 @@
25412541
- images
25422542

25432543

2544-
- title: Codex CLI to automatically fix CI failures
2544+
- title: Use Codex CLI to automatically fix CI failures
25452545
path: examples/codex/Autofix-github-actions.ipynb
25462546
date: 2025-09-30
25472547
authors:
25482548
- himadri518
25492549
- alwell-kevin
2550+
- charlie-openai
25502551
tags:
25512552
- codex
25522553

0 commit comments

Comments
 (0)