|
| 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