diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 373af0d..40ec896 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -28,8 +28,4 @@ jobs: id: codex uses: https://gitea.jsc.idv.tw/composite-actions/codex@v${{ needs.release-tag-version.outputs.version }} with: - oauth: ${{ secrets.CODEX_OAUTH }} prompt: "請自我介紹" - - name: 檢查登入帳號 - if: ${{ steps.codex.outputs.email != vars.CODEX_EMAIL }} - run: exit 1 diff --git a/action.yml b/action.yml index 0a325e9..2886409 100644 --- a/action.yml +++ b/action.yml @@ -6,22 +6,16 @@ inputs: description: '傳給 Codex CLI 的提示詞' required: false default: "請自我介紹" - oauth: - description: 'base64 編碼的 Codex OAuth token 檔案內容' - required: true outputs: text: description: '輸出的文字' value: ${{ steps.codex.outputs.text }} - email: - description: '目前登入帳號的電子郵件(由 codex app-server account/read 取得)' - value: ${{ steps.account.outputs.email }} runs: using: 'composite' steps: - name: 安裝工具 env: - OAUTH: ${{ inputs.oauth }} + OAUTH: ${{ secrets.CODEX_OAUTH }} run: | npm install -g @openai/codex @@ -49,9 +43,19 @@ runs: echo 'CODEX_OUTPUT' } >> "$GITHUB_OUTPUT" shell: bash - - name: 取得登入帳號 - id: account + - name: 驗證登入帳號 + env: + EXPECTED_EMAIL: ${{ vars.CODEX_EMAIL }} run: | + if [ -z "$EXPECTED_EMAIL" ]; then + echo 'CODEX_EMAIL repository variable is required.' >&2 + exit 1 + fi + email="$(python3 "$GITHUB_ACTION_PATH/app/codex_account.py")" - printf 'email=%s\n' "$email" >> "$GITHUB_OUTPUT" + if [ "$email" != "$EXPECTED_EMAIL" ]; then + echo '登入帳號與 CODEX_EMAIL 不符' >&2 + exit 1 + fi + echo '登入帳號驗證通過' shell: bash