From 08890b5b9d99e8517bdcef86b234dfe21828a19e Mon Sep 17 00:00:00 2001 From: Jeffery Date: Mon, 29 Jun 2026 13:35:42 +0800 Subject: [PATCH] =?UTF-8?q?fix(codex):=20=E6=94=B9=E7=94=B1=20job=20?= =?UTF-8?q?=E5=B1=A4=20env=20=E5=BE=9E=20secrets=20=E6=B3=A8=E5=85=A5=20CO?= =?UTF-8?q?DEX=5FOAUTH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit composite action 內無法解析 secrets context(Gitea 與 GitHub 皆然, vars 可、secrets 不可),導致 OAUTH 為空。改由呼叫端 workflow 在 job 層 以 env: CODEX_OAUTH: ${{ secrets.CODEX_OAUTH }} 注入,action 從繼承的 環境變數讀取並加空值把關;secret 仍源自 secrets、不經 inputs 傳遞。 --- .gitea/workflows/ci.yaml | 2 ++ action.yml | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 40ec896..3db0222 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -23,6 +23,8 @@ jobs: name: Codex runs-on: ubuntu needs: release-tag-version + env: + CODEX_OAUTH: ${{ secrets.CODEX_OAUTH }} steps: - name: 測試工具 id: codex diff --git a/action.yml b/action.yml index 2886409..80abb0a 100644 --- a/action.yml +++ b/action.yml @@ -14,14 +14,17 @@ runs: using: 'composite' steps: - name: 安裝工具 - env: - OAUTH: ${{ secrets.CODEX_OAUTH }} run: | + if [ -z "$CODEX_OAUTH" ]; then + echo 'CODEX_OAUTH environment variable is required (set it from secrets.CODEX_OAUTH in the caller workflow).' >&2 + exit 1 + fi + npm install -g @openai/codex oauth_file="$HOME/.codex/auth.json" install -d -m 700 "$(dirname "$oauth_file")" - printf '%s' "$OAUTH" | base64 -d > "$oauth_file" + printf '%s' "$CODEX_OAUTH" | base64 -d > "$oauth_file" chmod 600 "$oauth_file" shell: bash - name: 執行工具