Files

51 lines
2.5 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================================
# 用途:安裝 Codex CLI,並將 base64 編碼的 OAuth 憑證解碼寫入設定檔的 Gitea Composite Action。
# 更新時間:2026/07/17 11:54:39
# ============================================================================
# action 名稱,會顯示於 Gitea Actions 介面與被引用時的識別
name: 'Setup Codex'
# action 用途說明,簡述此 composite action 的功能
description: '安裝 Codex CLI 並還原 OAuth 憑證的 Gitea Composite Action'
# action 作者
author: 'Jeffery'
# inputs:定義此 action 對外接受的輸入參數契約
inputs:
# oauthbase64 編碼的 OAuth 憑證字串,通常由呼叫端以 secret 傳入
oauth:
# 參數說明
description: 'base64 編碼的 OAuth 憑證字串(解碼後寫入 Codex 憑證檔)'
# 必填;缺少憑證則無法完成設定
required: true
# runs:定義此 action 的執行方式與步驟
runs:
# 執行類型為 composite(由多個 step 組成的組合式 action
using: 'composite'
# steps:依序執行的步驟清單
steps:
# 啟動橫幅 step:於 action 執行起始輸出名稱/用途/更新時間,方便日誌辨識
- name: 顯示 action 資訊
# 指定以 bash 執行 run 內容
shell: bash
# 以下 echo 為此 action 刻意設計的啟動輸出,維持分隔線與排版原樣,不做訊息格式正規化
run: |
echo "================================================"
echo "Action : Setup Codex"
echo "用途 : 安裝 Codex CLI 並還原 OAuth 憑證"
echo "更新時間: 2026/07/17 11:54:39"
echo "================================================"
# 安裝 Codex CLI(以 npm 全域安裝,單行指令)
- name: 安裝 Codex CLI
# 指定以 bash 執行 run 內容
shell: bash
# 以 npm 全域安裝官方 Codex 套件
run: npm install -g @openai/codex
# 將 base64 OAuth 憑證解碼並寫入 Codex 憑證檔(單行:建目錄 → 解碼寫檔 → 限縮權限;不輸出憑證內容)
- name: 寫入 OAuth 憑證
# 指定以 bash 執行 run 內容
shell: bash
# 環境變數:把 inputs.oauth 帶入環境供 run 使用(避免直接內嵌於指令列)
env:
OAUTH_B64: ${{ inputs.oauth }}
# 單行完成:mkdir 父目錄、base64 解碼寫入憑證檔、chmod 600 限縮權限
run: mkdir -p "$HOME/.codex" && printf '%s' "$OAUTH_B64" | base64 -d > "$HOME/.codex/auth.json" && chmod 600 "$HOME/.codex/auth.json"