Skip to content

Commit 4d1ce04

Browse files
authored
Set up codex for issues and PRs (#1214)
Following this guide: https://github.com/openai/codex/tree/main/.github/actions/codex
1 parent c5d5010 commit 4d1ce04

File tree

5 files changed

+84
-0
lines changed

5 files changed

+84
-0
lines changed

.github/codex/home/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
model = "o3"

.github/codex/labels/codex-attempt.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Attempt to solve the reported issue.
2+
3+
If a code change is required, create a new branch, commit the fix, and open a pull request that resolves the problem.
4+
5+
Here is the original GitHub issue that triggered this run:
6+
7+
### {CODEX_ACTION_ISSUE_TITLE}
8+
9+
{CODEX_ACTION_ISSUE_BODY}

.github/codex/labels/codex-review.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Review this PR and respond with a very concise final message, formatted in Markdown.
2+
3+
There should be a summary of the changes (1-2 sentences) and a few bullet points if necessary.
4+
5+
Then provide the **review** (1-2 sentences plus bullet points, friendly tone).
6+
7+
{CODEX_ACTION_GITHUB_EVENT_PATH} contains the JSON that triggered this GitHub workflow. It contains the `base` and `head` refs that define this PR. Both refs are available locally.

.github/codex/labels/codex-triage.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Troubleshoot whether the reported issue is valid.
2+
3+
Provide a concise and respectful comment summarizing the findings.
4+
5+
### {CODEX_ACTION_ISSUE_TITLE}
6+
7+
{CODEX_ACTION_ISSUE_BODY}

.github/workflows/codex.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Codex
2+
3+
on:
4+
issues:
5+
types: [opened, labeled]
6+
pull_request:
7+
branches: [main]
8+
types: [labeled]
9+
10+
jobs:
11+
codex:
12+
# This `if` check provides complex filtering logic to avoid running Codex
13+
# on every PR. Admittedly, one thing this does not verify is whether the
14+
# sender has write access to the repo: that must be done as part of a
15+
# runtime step.
16+
#
17+
# Note the label values should match the ones in the .github/codex/labels
18+
# folder.
19+
if: |
20+
(github.event_name == 'issues' && (
21+
(github.event.action == 'labeled' && (github.event.label.name == 'codex-attempt' || github.event.label.name == 'codex-triage'))
22+
)) ||
23+
(github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'codex-review')
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write # can push or create branches
27+
issues: write # for comments + labels on issues/PRs
28+
pull-requests: write # for PR comments/labels
29+
steps:
30+
# TODO: Consider adding an optional mode (--dry-run?) to actions/codex
31+
# that verifies whether Codex should actually be run for this event.
32+
# (For example, it may be rejected because the sender does not have
33+
# write access to the repo.) The benefit would be two-fold:
34+
# 1. As the first step of this job, it gives us a chance to add a reaction
35+
# or comment to the PR/issue ASAP to "ack" the request.
36+
# 2. It saves resources by skipping the clone and setup steps below if
37+
# Codex is not going to run.
38+
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
42+
# We install the dependencies like we would for an ordinary CI job,
43+
# particularly because Codex will not have network access to install
44+
# these dependencies.
45+
- name: Setup uv
46+
uses: astral-sh/setup-uv@v5
47+
with:
48+
enable-cache: true
49+
50+
- name: Install dependencies
51+
run: make sync
52+
53+
# Note it is possible that the `verify` step internal to Run Codex will
54+
# fail, in which case the work to setup the repo was worthless :(
55+
- name: Run Codex
56+
uses: ./.github/actions/codex
57+
with:
58+
openai_api_key: ${{ secrets.PROD_OPENAI_API_KEY }}
59+
github_token: ${{ secrets.GITHUB_TOKEN }}
60+
codex_home: ./.github/codex/home

0 commit comments

Comments
 (0)