-
Notifications
You must be signed in to change notification settings - Fork 15
92 lines (82 loc) · 3.18 KB
/
Copy pathcodex-pr.yaml
File metadata and controls
92 lines (82 loc) · 3.18 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
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Codex PR Creation
on:
issue_comment:
types: [created]
jobs:
codex-pr:
name: Create PR with Codex
runs-on: ubuntu-latest
if: |
startsWith(github.event.comment.body, '/codex') &&
github.event.comment.user.login == github.repository_owner
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Codex
id: run_codex
uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
model: gpt-5.1-codex-max
prompt: |
Issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}
${{ github.event.issue.body }}
This repository is a TypeScript SignalR client library.
Please implement code changes to address the above issue.
Keep changes to a minimum and only modify what is necessary.
sandbox: workspace-write
safety-strategy: drop-sudo
- name: Create Pull Request
id: create_pr
uses: peter-evans/create-pull-request@v8
with:
branch: codex/issue-${{ github.event.issue.number }}
branch-suffix: timestamp
commit-message: Address issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}
title: '[Codex] Address issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}'
body: |
This PR was automatically created by Codex to address issue #${{ github.event.issue.number }}.
base: main
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
- name: Comment on issue
if: steps.create_pr.outputs.pull-request-number != ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: `✅ PR created: #${{ steps.create_pr.outputs.pull-request-number }}
});
- name: Comment on issue (no changes)
if: steps.create_pr.outputs.pull-request-number == ''
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: 'ℹ️ Codex ran but no changes were made.',
});
- name: Handle errors
if: failure()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.issue.number,
body: '❌ An error occurred while running Codex. Please check the workflow logs.',
});