2020 type : string
2121 default : ' '
2222 secrets :
23+ OPENAI_API_KEY :
24+ required : false
2325 CODEX_AUTH_JSON :
2426 required : false
2527 WINDMILL_EE_PRIVATE_ACCESS :
@@ -60,13 +62,18 @@ jobs:
6062 - name : Check Codex configuration
6163 id : codex_config
6264 env :
65+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
6366 CODEX_AUTH_JSON : ${{ secrets.CODEX_AUTH_JSON }}
6467 run : |
65- if [ -n "$CODEX_AUTH_JSON" ]; then
68+ if [ -n "$OPENAI_API_KEY" ]; then
69+ echo "enabled=true" >> "$GITHUB_OUTPUT"
70+ echo "auth_mode=api_key" >> "$GITHUB_OUTPUT"
71+ elif [ -n "$CODEX_AUTH_JSON" ]; then
6672 echo "enabled=true" >> "$GITHUB_OUTPUT"
73+ echo "auth_mode=oauth_json" >> "$GITHUB_OUTPUT"
6774 else
6875 echo "enabled=false" >> "$GITHUB_OUTPUT"
69- echo "CODEX_AUTH_JSON is not configured; skipping Codex review."
76+ echo "Codex auth is not configured; set OPENAI_API_KEY or CODEX_AUTH_JSON to enable Codex review."
7077 fi
7178
7279 - name : Resolve PR metadata
@@ -169,9 +176,10 @@ jobs:
169176 if : steps.codex_config.outputs.enabled == 'true' && steps.pr.outputs.skip != 'true'
170177 run : npm install --global @openai/codex@0.128.0
171178
172- - name : Configure file-backed Codex auth
179+ - name : Configure Codex auth
173180 if : steps.codex_config.outputs.enabled == 'true' && steps.pr.outputs.skip != 'true'
174181 env :
182+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY }}
175183 CODEX_AUTH_JSON : ${{ secrets.CODEX_AUTH_JSON }}
176184 run : |
177185 CODEX_HOME="$HOME/.codex"
@@ -181,9 +189,13 @@ jobs:
181189 cat > "$CODEX_HOME/config.toml" <<'EOF'
182190 cli_auth_credentials_store = "file"
183191 EOF
184- printf '%s' "$CODEX_AUTH_JSON" > "$CODEX_HOME/auth.json"
185- chmod 600 "$CODEX_HOME/auth.json"
186- node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$CODEX_HOME/auth.json"
192+ if [ -n "$OPENAI_API_KEY" ]; then
193+ printf '%s' "$OPENAI_API_KEY" | codex login --with-api-key
194+ else
195+ printf '%s' "$CODEX_AUTH_JSON" > "$CODEX_HOME/auth.json"
196+ chmod 600 "$CODEX_HOME/auth.json"
197+ node -e 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8"))' "$CODEX_HOME/auth.json"
198+ fi
187199
188200 - name : Pre-fetch base and head refs for the PR
189201 if : steps.codex_config.outputs.enabled == 'true' && steps.pr.outputs.skip != 'true'
0 commit comments