feat: setup-claude 改為安裝 Claude Code CLI 並還原 OAuth 憑證,CI 移至 .gitea/workflows #1

Merged
admin merged 4 commits from ai-review-resolve/master-20260717-125158 into develop 2026-07-17 09:06:15 +00:00
Showing only changes of commit 3b3bb8058d - Show all commits
+43 -15
View File
@@ -1,22 +1,50 @@
name: 'Gitea Composite Template' # ============================================================================
description: 'Gitea Composite 範本' # 用途:安裝 Claude Code CLI,並將 base64 編碼的 OAuth 憑證解碼寫入設定檔的 Gitea Composite Action。
# 更新時間:2026/07/17 11:54:39
# ============================================================================
# action 名稱,顯示於 Gitea Actions UI 與被其他 workflow 引用時的識別名稱
name: 'Setup Claude'
# action 用途描述,說明此 composite action 的目的
description: '安裝 Claude Code CLI 並還原 OAuth 憑證的 Gitea Composite Action'
# action 作者
author: 'Jeffery' author: 'Jeffery'
# 輸入參數契約:定義呼叫端可傳入的參數
inputs: inputs:
message: # oauthbase64 編碼的 OAuth 憑證字串,通常由呼叫端以 secret 傳入
description: '輸入訊息' oauth:
required: false # 參數說明
default: 'Hello, World!' description: 'base64 編碼的 OAuth 憑證字串(解碼後寫入 Claude 憑證檔)'
outputs: # 必填;缺少憑證則無法完成設定
message: required: true
description: '輸出訊息' # 執行定義區塊
value: ${{ steps.exchange.outputs.message }}
runs: runs:
# 指定為 composite(複合)action,由多個 step 組成
using: 'composite' using: 'composite'
# 依序執行的步驟清單
steps: steps:
- name: Exchange # 啟動橫幅 step:於 action 開始時印出 action 名稱/用途/更新時間,方便日誌辨識
id: exchange - name: 顯示 action 資訊
# 使用 bash shell 執行
shell: bash shell: bash
env: # 刻意設計的啟動輸出,以分隔線包住 action 基本資訊(各 echo 行為刻意保留的橫幅格式,勿改寫)
MESSAGE: ${{ inputs.message }}
run: | run: |
echo "message=$MESSAGE" >> "$GITHUB_OUTPUT" echo "================================================"
echo "Action : Setup Claude"
echo "用途 : 安裝 Claude Code CLI 並還原 OAuth 憑證"
echo "更新時間: 2026/07/17 11:54:39"
echo "================================================"
# 安裝 Claude Code CLI(以 npm 全域安裝,單行指令)
- name: 安裝 Claude Code CLI
# 使用 bash shell 執行
shell: bash
# 以 npm 全域安裝官方 Claude Code 套件
run: npm install -g @anthropic-ai/claude-code
# 將 base64 OAuth 憑證解碼並寫入 Claude 憑證檔(單行:建目錄 → 解碼寫檔 → 限縮權限;不輸出憑證內容)
- name: 寫入 OAuth 憑證
# 使用 bash shell 執行
shell: bash
# 環境變數:把 inputs.oauth 帶入環境供 run 使用(避免直接內嵌於指令列)
env:
OAUTH_B64: ${{ inputs.oauth }}
# 單行完成:mkdir 父目錄、base64 解碼寫入憑證檔、chmod 600 限縮權限
run: mkdir -p "$HOME/.claude" && printf '%s' "$OAUTH_B64" | base64 -d > "$HOME/.claude/.credentials.json" && chmod 600 "$HOME/.claude/.credentials.json"