Skip to content

Instantly share code, notes, and snippets.

@sgoedecke
Last active June 27, 2025 15:48
Show Gist options
  • Save sgoedecke/2b4e8d5e6b21f536ea399f1728916ad5 to your computer and use it in GitHub Desktop.
Save sgoedecke/2b4e8d5e6b21f536ea399f1728916ad5 to your computer and use it in GitHub Desktop.
Drop-in Codex AI agent with GitHub Models

This is a drop-in, zero-config Actions harness for OpenAI's Codex agent. It uses GitHub Models for inference, so you don't need to set up any secrets - just copy-pasting the action into your repo should work as-is.

You may need to go into your settings and check the "allow Actions to open PRs" checkbox.

To use it, open an issue in your repo with [codex] in the issue name.

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: Process issue with Codex
env:
OPENAI_API_KEY: ${{ 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
export OPENAI_BASE_URL=https://models.github.ai/inference
# any provider string would work here, it's just so codex knows it's using a custom model
codex --approval-mode full-auto --provider github --model openai/gpt-4.1 --quiet "$INSTRUCTION"
if [[ -n $(git status --porcelain) ]]; then
git config user.name "GitHub Models Codex Bot"
git config user.email "[email protected]"
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
@madhugilla
Copy link

Hi thank you for this, can you share few example prompts (in the issue) that you used if you don't mind, doesnt matter what i specify in the body i always run into "Codex processed this issue but made no changes".

@sgoedecke
Copy link
Author

I tried it with some test prompts like "can you remove this Action workflow I'm not using", or "can you add a README to this project". I think you could probably remove --quiet and read the workflow log to get a better sense of what Codex is doing and thinking about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment