From 0d6a19823312e5e8126456460d314bccc093c842 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 3 Jul 2026 17:52:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?feat(ci):=20=E9=99=90=E5=88=B6=20CI=20?= =?UTF-8?q?=E5=83=85=E5=9C=A8=20master/develop=20=E7=9A=84=20PR=20?= =?UTF-8?q?=E8=A7=B8=E7=99=BC=E4=B8=A6=E4=BF=AE=E6=AD=A3=20test=20?= =?UTF-8?q?=E5=9F=B7=E8=A1=8C=E6=A2=9D=E4=BB=B6=E7=82=BA=20is=5Fbeta=20=3D?= =?UTF-8?q?=3D=20'true'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yaml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 53a15aa..0f2d003 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -1,11 +1,13 @@ # ============================================================================= # CI Workflow(Gitea Actions) # 用途:在 Pull Request 開啟或更新時觸發的持續整合流程,依序執行三個 job: -# 1. BUILD - 發佈 Gitea Release(beta 版本號取自 run_number)。 -# 2. TEST - checkout 原始碼,執行本 composite action(setup-codex), -# 再用 codex exec 產生「自我介紹」文字,透過 heredoc 寫入 job output。 +# 1. BUILD - 發佈 Gitea Release(beta 版本號取自 run_number),並輸出 is_beta。 +# 2. TEST - 依 BUILD 輸出的 is_beta 決定是否執行;checkout 原始碼,執行本 +# composite action(setup-codex),再用 codex exec 產生「自我介紹」 +# 文字,透過 heredoc 寫入 job output。 # 3. RESULT - 顯示 TEST job 輸出的 message,用於驗證整條流程串接成功。 -# 更新日期:2026/07/03 11:41:20 +# 另外,CI 僅在 base 分支為 master 或 develop 的 Pull Request 觸發。 +# 更新日期:2026/07/03 17:43:30 # ============================================================================= # workflow 名稱,會顯示在 Gitea Actions 的執行清單中。 @@ -14,6 +16,12 @@ name: CI on: # 監聽 Pull Request 事件。 pull_request: + # 限制只有當 PR 的目標(base)分支為 master 或 develop 時才觸發此 CI。 + branches: + # 納入的目標分支:master。 + - master + # 納入的目標分支:develop。 + - develop # 僅在 PR「開啟」(opened) 或「有新 commit 推送 / 更新」(synchronize) 時觸發, # 避免 closed / reopened 等其他事件也啟動整條 CI。 types: [opened, synchronize] @@ -30,7 +38,12 @@ jobs: # 版本號規則:固定 0.0.0-beta. 前綴 + Gitea 的執行流水號 run_number, # 讓每次 CI 產生遞增且唯一的 beta 版本字串。 VERSION: "0.0.0-beta.${{ gitea.run_number }}" + # 定義此 job 對外輸出,供後續 job(test)取用其判斷結果。 outputs: + # 【需人工確認】將環境變數 IS_BETA 暴露為 job 層級的 is_beta 輸出;但本 job 的 + # env 只定義了 VERSION、並未定義 IS_BETA,因此 env.IS_BETA 會取到空字串, + # 配合 test 的 if ... == 'true' 判斷,將導致 test job 永遠被略過。 + # 此行內容維持原樣不修改,請人工確認是否應補上 IS_BETA 的設定。 is_beta: ${{ env.IS_BETA }} # 此 job 的執行步驟。 steps: @@ -58,7 +71,9 @@ jobs: runs-on: ubuntu # 相依關係:需等 build job 成功後才執行。 needs: [build] - if: ${{ needs.build.outputs.is_beta }} + # 執行條件:僅當 build job 的 is_beta 輸出等於字串 'true' 時才執行本 test job; + # 否則整個 test job 會被略過。 + if: ${{ needs.build.outputs.is_beta == 'true' }} # 定義此 job 對外輸出,供後續 job(result)取用。 outputs: # 將名為 execute 的步驟輸出的 message,暴露為 job 層級的 message 輸出。 -- 2.53.0 From e839b747544647944cacf211e6a1a66abaa30438 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 3 Jul 2026 17:52:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?docs(=E6=8C=87=E4=BB=A4=E6=AA=94=E8=88=87?= =?UTF-8?q?=20README):=20=E8=A3=9C=E9=BD=8A=20action/master=20=E9=80=90?= =?UTF-8?q?=E8=A1=8C=E8=A8=BB=E8=A7=A3=E4=B8=A6=E6=9B=B4=E6=96=B0=20README?= =?UTF-8?q?=20=E8=88=87=20CI=20=E8=A7=B8=E7=99=BC=E8=AA=AA=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/master.yaml | 3 ++- README.md | 8 +++++--- action.yml | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/master.yaml b/.gitea/workflows/master.yaml index c9c7545..9088837 100644 --- a/.gitea/workflows/master.yaml +++ b/.gitea/workflows/master.yaml @@ -3,7 +3,7 @@ # 本 workflow 為「CD(持續部署)」流程,於程式碼 push 到 master 分支時觸發。 # 主要工作為 checkout 完整原始碼、依指定 commit 反查其所屬的 git tag, # 並將該 tag 輸出顯示,供後續部署或版本追蹤使用。 -# 更新日期:2026/07/03 11:41:20 (Asia/Taipei) +# 更新日期:2026/07/03 17:43:30 (Asia/Taipei) # ============================================================================= # workflow 名稱,顯示於 Gitea Actions 介面 @@ -36,6 +36,7 @@ jobs: - name: Source Code Checkout # 使用 actions/checkout,版本由 repo/organization 變數 ACTION_CHECKOUT_VERSION 決定 uses: actions/checkout@${{ vars.ACTION_CHECKOUT_VERSION }} + # with:傳入 checkout action 的參數區塊 with: # fetch-depth: 0 代表抓取完整 git 歷史(含所有 tag), # 以利後續 git describe 能正確反查 tag(淺層 clone 會導致查不到)。 diff --git a/README.md b/README.md index a208728..57dc327 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # setup-codex -> 更新時間:2026/07/03 11:45:51 +> 更新時間:2026/07/03 17:43:30 `setup-codex` 是一個 **Gitea composite action**,用於在 Gitea Actions runner 上安裝並登入 [Codex CLI](https://chatgpt.com/codex),讓後續 workflow 步驟能直接呼叫已完成 OAuth 登入的 `codex` 指令。本 repo 由 action 定義(`action.yml`)與示範用的 CI/CD workflow 組成,內容皆為 YAML 與少量 shell/Node,**不含可列入 README 的公開程式方法**。 @@ -10,7 +10,7 @@ | 專案名稱 | 專案描述 | | --- | --- | -| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | Gitea composite action:安裝 Codex CLI、以 base64 編碼的 OAuth 驗證檔完成登入,並顯示目前登入帳號;另附 CI(PR 發佈 Release + 執行 action)與 CD(push master 反查 commit tag)示範 workflow。 | +| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | Gitea composite action:安裝 Codex CLI、以 base64 編碼的 OAuth 驗證檔完成登入,並顯示目前登入帳號;另附 CI(僅在 base 為 master/develop 的 PR 觸發,發佈 Release、依 is_beta 條件執行 codex 測試)與 CD(push master 反查 commit tag)示範 workflow。 | ### 參考專案 @@ -69,5 +69,7 @@ jobs: | 檔案 | 觸發時機 | 用途 | | --- | --- | --- | | [action.yml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/action.yml) | 被其他 workflow 以 `uses` 引用 | 定義安裝/登入 Codex 的 composite action。 | -| [.gitea/workflows/ci.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/ci.yaml) | Pull Request `opened`/`synchronize` | 發佈 beta Release、執行本 action 並以 `codex exec` 產生自我介紹、顯示結果。 | +| [.gitea/workflows/ci.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/ci.yaml) | base 為 `master`/`develop` 的 Pull Request(`opened`/`synchronize`) | 發佈 beta Release、輸出 `is_beta`,並在 `is_beta == 'true'` 時執行本 action 以 `codex exec` 產生自我介紹、顯示結果。 | | [.gitea/workflows/master.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/master.yaml) | push 至 `master` | 反查指定 commit 所屬的 git tag 並顯示。 | + +> ⚠️ 注意:`ci.yaml` 的 `build` job 目前輸出的 `is_beta` 取自 `env.IS_BETA`,但該 env 未定義,實務上 `is_beta` 會是空字串、導致 `test` job 被略過;`action.yml` 的 `outputs.message` 參照的 `steps.exchange` 步驟亦不存在。以上為既有、待人工確認事項。 diff --git a/action.yml b/action.yml index 30309b8..94ba427 100644 --- a/action.yml +++ b/action.yml @@ -5,7 +5,7 @@ # 2) 使用外部傳入、經 base64 編碼的 OAuth 驗證檔完成 Codex 登入。 # 3) 解析登入驗證檔中的 id_token,輸出目前登入的帳號 email 以供確認。 # 使用情境:讓後續 workflow 步驟可直接呼叫已登入的 Codex CLI。 -# 更新日期:2026/07/03 11:41:20 +# 更新日期:2026/07/03 17:33:39 # ============================================================================= # action 名稱:顯示於 Gitea/GitHub Actions UI 上的識別名稱 -- 2.53.0 From 89f120e8592ded216977a019670efb8a759ed38d Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 3 Jul 2026 18:03:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix(ci):=20=E8=A3=9C=E4=B8=8A=20IS=5FBETA?= =?UTF-8?q?=20env=20=E4=B8=A6=E8=AE=93=20prerelease=20=E6=B2=BF=E7=94=A8?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=20test=20=E4=BE=9D=20base=20=E5=88=86?= =?UTF-8?q?=E6=94=AF=E6=AD=A3=E7=A2=BA=E5=9F=B7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yaml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 0f2d003..91c15a8 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -7,7 +7,7 @@ # 文字,透過 heredoc 寫入 job output。 # 3. RESULT - 顯示 TEST job 輸出的 message,用於驗證整條流程串接成功。 # 另外,CI 僅在 base 分支為 master 或 develop 的 Pull Request 觸發。 -# 更新日期:2026/07/03 17:43:30 +# 更新日期:2026/07/03 17:56:45 # ============================================================================= # workflow 名稱,會顯示在 Gitea Actions 的執行清單中。 @@ -38,12 +38,13 @@ jobs: # 版本號規則:固定 0.0.0-beta. 前綴 + Gitea 的執行流水號 run_number, # 讓每次 CI 產生遞增且唯一的 beta 版本字串。 VERSION: "0.0.0-beta.${{ gitea.run_number }}" + # 定義環境變數 IS_BETA:當 PR 的 base 分支為 develop 時為字串 'true',否則為 'false'; + # 作為下方 is_beta 輸出的來源,用來決定 test job 是否執行。 + IS_BETA: ${{ gitea.base_ref == 'develop' }} # 定義此 job 對外輸出,供後續 job(test)取用其判斷結果。 outputs: - # 【需人工確認】將環境變數 IS_BETA 暴露為 job 層級的 is_beta 輸出;但本 job 的 - # env 只定義了 VERSION、並未定義 IS_BETA,因此 env.IS_BETA 會取到空字串, - # 配合 test 的 if ... == 'true' 判斷,將導致 test job 永遠被略過。 - # 此行內容維持原樣不修改,請人工確認是否應補上 IS_BETA 的設定。 + # 將環境變數 IS_BETA 暴露為 job 層級的 is_beta 輸出;當 PR base 分支為 develop 時為 'true', + # 供 test job 以 `if ... == 'true'` 判斷是否執行(即:僅 develop 的 PR 會跑 test)。 is_beta: ${{ env.IS_BETA }} # 此 job 的執行步驟。 steps: @@ -62,7 +63,7 @@ jobs: target_commitish: ${{ gitea.sha }} # 是否標記為「預發佈」(prerelease):當 PR 目標分支 base_ref 為 develop 時為 true, # 代表流向 develop 的變更視為預發佈版本。 - prerelease: ${{ gitea.base_ref == 'develop' }} + prerelease: ${{ env.IS_BETA }} # ---- Job 2:TEST(執行 setup-codex 並產生自我介紹)---- test: # job 顯示名稱。 -- 2.53.0 From be01444f71fac06dc4ad269f03fb3b06d2f58c45 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 3 Jul 2026 18:03:32 +0800 Subject: [PATCH 4/4] =?UTF-8?q?docs(README):=20=E6=9B=B4=E6=96=B0=E6=99=82?= =?UTF-8?q?=E9=96=93=E4=B8=A6=E4=BF=AE=E6=AD=A3=20CI=20is=5Fbeta=20?= =?UTF-8?q?=E8=AA=AA=E6=98=8E=E3=80=81=E7=A7=BB=E9=99=A4=E5=B7=B2=E4=BF=AE?= =?UTF-8?q?=E5=BE=A9=E7=9A=84=E8=A8=BB=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 57dc327..1dffd5d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # setup-codex -> 更新時間:2026/07/03 17:43:30 +> 更新時間:2026/07/03 17:56:45 `setup-codex` 是一個 **Gitea composite action**,用於在 Gitea Actions runner 上安裝並登入 [Codex CLI](https://chatgpt.com/codex),讓後續 workflow 步驟能直接呼叫已完成 OAuth 登入的 `codex` 指令。本 repo 由 action 定義(`action.yml`)與示範用的 CI/CD workflow 組成,內容皆為 YAML 與少量 shell/Node,**不含可列入 README 的公開程式方法**。 @@ -10,7 +10,7 @@ | 專案名稱 | 專案描述 | | --- | --- | -| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | Gitea composite action:安裝 Codex CLI、以 base64 編碼的 OAuth 驗證檔完成登入,並顯示目前登入帳號;另附 CI(僅在 base 為 master/develop 的 PR 觸發,發佈 Release、依 is_beta 條件執行 codex 測試)與 CD(push master 反查 commit tag)示範 workflow。 | +| [setup-codex](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop) | Gitea composite action:安裝 Codex CLI、以 base64 編碼的 OAuth 驗證檔完成登入,並顯示目前登入帳號;另附 CI(僅在 base 為 master/develop 的 PR 觸發,發佈 Release、依 is_beta 決定是否執行 codex 測試)與 CD(push master 反查 commit tag)示範 workflow。 | ### 參考專案 @@ -69,7 +69,7 @@ jobs: | 檔案 | 觸發時機 | 用途 | | --- | --- | --- | | [action.yml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/action.yml) | 被其他 workflow 以 `uses` 引用 | 定義安裝/登入 Codex 的 composite action。 | -| [.gitea/workflows/ci.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/ci.yaml) | base 為 `master`/`develop` 的 Pull Request(`opened`/`synchronize`) | 發佈 beta Release、輸出 `is_beta`,並在 `is_beta == 'true'` 時執行本 action 以 `codex exec` 產生自我介紹、顯示結果。 | +| [.gitea/workflows/ci.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/ci.yaml) | base 為 `master`/`develop` 的 Pull Request(`opened`/`synchronize`) | 發佈 beta Release;`build` 依 `base_ref == 'develop'` 設定 `IS_BETA` 並輸出 `is_beta`,當 `is_beta == 'true'`(即 develop 的 PR)時執行本 action 以 `codex exec` 產生自我介紹、顯示結果。 | | [.gitea/workflows/master.yaml](https://gitea.jsc.idv.tw/actions/setup-codex/src/branch/develop/.gitea/workflows/master.yaml) | push 至 `master` | 反查指定 commit 所屬的 git tag 並顯示。 | -> ⚠️ 注意:`ci.yaml` 的 `build` job 目前輸出的 `is_beta` 取自 `env.IS_BETA`,但該 env 未定義,實務上 `is_beta` 會是空字串、導致 `test` job 被略過;`action.yml` 的 `outputs.message` 參照的 `steps.exchange` 步驟亦不存在。以上為既有、待人工確認事項。 +> ⚠️ 注意(既有、待人工確認):`action.yml` 的 `outputs.message` 參照的 `steps.exchange` 步驟不存在,該 output 可能取不到值。 -- 2.53.0