-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (64 loc) · 2.52 KB
/
codex.yml
File metadata and controls
78 lines (64 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Source: https://gist.github.com/sgoedecke/2b4e8d5e6b21f536ea399f1728916ad5
name: Codex on GitHub Models
on:
issues:
types: [opened]
jobs:
process-issue:
if: contains(github.event.issue.title, '[codex]')
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
models: read
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
- name: Install Codex CLI
run: npm install -g @openai/codex
- name: Configure Codex for GitHub Models
run: |
mkdir -p ~/.codex
cat > ~/.codex/config.toml << 'EOF'
model = "openai/gpt-4.1"
model_provider = "github-models"
approval_policy = "never"
[model_providers.github-models]
name = "GitHub Models"
base_url = "https://models.github.ai/inference"
env_key = "GITHUB_TOKEN"
wire_api = "chat"
EOF
- name: Process issue with Codex
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_BODY: ${{ github.event.issue.body }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
INSTRUCTION="$ISSUE_TITLE --- $ISSUE_BODY"
BRANCH_NAME="codex/issue-$ISSUE_NUMBER"
git checkout -b $BRANCH_NAME
# Use the configured GitHub Models provider
codex --full-auto "$INSTRUCTION"
if [[ -n $(git status --porcelain) ]]; then
git config user.name "GitHub Models Codex Bot"
git config user.email "github-models-codex-bot@noreply.github.com"
git add .
git commit -m "Codex changes for issue #$ISSUE_NUMBER"
git push origin $BRANCH_NAME
# Create PR and comment on issue using the same token
gh pr create --title "Codex: ${{ github.event.issue.title }}" \
--body "Auto-generated by Codex for issue #$ISSUE_NUMBER" \
--base ${{ github.event.repository.default_branch }} \
--head $BRANCH_NAME
gh issue comment $ISSUE_NUMBER --body "Codex created a PR for this issue"
else
gh issue comment $ISSUE_NUMBER --body "Codex processed this issue but made no changes"
fi