Runing codex in github action

Resolved 💬 7 comments Opened Apr 19, 2025 by JuHyung-Son Closed Apr 23, 2025

What is the type of issue?

_No response_

What is the issue?

I followed this in action

- name: Update changelog via Codex
  run: |
    npm install -g @openai/codex
    export OPENAI_API_KEY="${{ secrets.OPENAI_KEY }}"
    codex -a auto-edit --quiet "update CHANGELOG for next release"

but It failed with

{"role":"user","content":[{"type":"input_text","text":"Plz review code 1) Explain what this PR does\\n2) Code review and suggestions for improvement\\n3) Detect bugs and potential bugs. \\nUpdate in review.md in korean language"}],"type":"message"}
Please pass patch text through stdin

Also, I test in local linux,

root@43d1ec8385b1:/codex# cat READMD.md | codex -q -a auto-edit "summary"
{"role":"user","content":[{"type":"input_text","text":"summary"}],"type":"message"}
Patch must start with *** Begin Patch\n

so I added *** Begin Patch\n on REDME.md and I got,

root@2deea6cb9463:~/codex# cat README.md | codex --full-auto -q "here "
{"role":"user","content":[{"type":"input_text","text":"here "}],"type":"message"}
Invalid patch text

Where did you find it?

_No response_

View original on GitHub ↗

7 Comments

eriklueth · 1 year ago

Same here, the github action fails with "Please pass patch text through stdin"

    - name: Generate fixes with Codex CLI (CI mode)
      env:
        OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
      run: |
        # Build instruction from issue
        INSTR="Fix the following issue: #${{ github.event.issue.number }} - ${{ github.event.issue.title }}. ${{ github.event.issue.body }}"
        # Run in non-interactive auto-edit mode: prompt first, then approval mode flag
        codex -a auto-edit --quiet "$INSTR"
nasirus · 1 year ago

+1

Bhavikpatel576 · 1 year ago

Are you guys using this to review PRs?

jordan-cutler · 1 year ago

+1

JuHyung-Son · 1 year ago

@Bhavikpatel576 yes. Im trying to make an action

JuHyung-Son · 1 year ago

I tried codex to fix codex. not sure it works. Anyone can try this?

codex comments:

I’ve updated the source so that in --quiet mode, when running in auto-edit (or full-auto) mode, it no longer just dumps the patch to stdout and exits. Instead, it now follows the normal interactive auto-edit flow and actually applies the patch.

Key changes:
• In cli.tsx, inside the if (cli.flags.quiet) block:
• Suggest mode still calls runQuietMode() and exits immediately.
• Auto-edit and full-auto modes now skip runQuietMode() and fall through into the interactive code path that applies the patch.
• As a result, running codex -a auto-edit --quiet … in CI will automatically apply the patch without triggering the “Please pass patch text through stdin” error.

diff --git a/codex-cli/src/cli.tsx b/codex-cli/src/cli.tsx
index 0bed07b..f294e23 100644
--- a/codex-cli/src/cli.tsx
+++ b/codex-cli/src/cli.tsx
@@ -361,15 +361,18 @@ if (cli.flags.quiet) {
       ? AutoApprovalMode.AUTO_EDIT
       : config.approvalMode || AutoApprovalMode.SUGGEST;
 
-  await runQuietMode({
-    prompt,
-    imagePaths: imagePaths || [],
-    approvalPolicy: quietApprovalPolicy,
-    additionalWritableRoots,
-    config,
-  });
-  onExit();
-  process.exit(0);
+  // In quiet mode, only use the non-interactive runner when in suggest mode.
+  if (quietApprovalPolicy === AutoApprovalMode.SUGGEST) {
+    await runQuietMode({
+      prompt,
+      imagePaths: imagePaths || [],
+      approvalPolicy: quietApprovalPolicy,
+      additionalWritableRoots,
+      config,
+    });
+    onExit();
+    process.exit(0);
+  }
 }
 
 // Default to the "suggest" policy.
JuHyung-Son · 1 year ago

I checked this bug is solved in latest version