調整:ci/cd 一致化(action-ci 自動偵測、action-cd)、版本計算抽到 next-version
This commit is contained in:
+17
-11
@@ -1,20 +1,17 @@
|
||||
name: action-ci
|
||||
description: "action repo 的共用 CI:shellcheck → Go 腳本測試(在 ci-env 容器裡,Go 版本取 go.mod)→ 建置映像檔。內部用的 shellcheck、ci-env 版本取自呼叫端的 Gitea 變數 ACTION_SHELLCHECK_VERSION、ACTION_CI_ENV_VERSION。要在 checkout 之後使用,各步驟用輸入開關"
|
||||
description: "action repo 的共用 CI:checkout → shellcheck → Go 腳本測試(有 go.mod 與 test/ 才跑,在 ci-env 容器裡,Go 版本取 go.mod)→ 建置映像檔(有 Dockerfile 才跑,可選擇實際執行並檢查輸出)。自動偵測,各 repo 的 ci.yaml 不必設開關。內部用的 shellcheck、ci-env 版本取自呼叫端的 Gitea 變數 ACTION_SHELLCHECK_VERSION、ACTION_CI_ENV_VERSION"
|
||||
inputs:
|
||||
checkout:
|
||||
description: "true=先 checkout;false=呼叫端已經 checkout(例如要用 uses: ./ 測自己)"
|
||||
default: "true"
|
||||
shellcheck_files:
|
||||
description: "shellcheck 要檢查的檔案(空白分隔,可用萬用字元);沒有符合的檔案就略過"
|
||||
default: "*.sh"
|
||||
go_test:
|
||||
description: "true=跑 Go 測試"
|
||||
default: "false"
|
||||
go_test_command:
|
||||
description: "go_test 為 true 時執行的指令"
|
||||
description: "有 go.mod 與 test/ 時執行的指令"
|
||||
default: "go vet ./... && go test ./test/"
|
||||
docker_build:
|
||||
description: "true=用 docker build 檢查 Dockerfile 建得起來(映像檔標籤唯一,不會撞到 runner 上的舊映像檔)"
|
||||
default: "false"
|
||||
docker_run_args:
|
||||
description: "docker_build 之後實際執行容器的參數(entrypoint 的參數,每行一個);空=不執行"
|
||||
description: "docker build 之後實際執行容器的參數(entrypoint 的參數,每行一個);空=只建置不執行"
|
||||
default: ""
|
||||
docker_run_options:
|
||||
description: "執行容器的 docker create 選項(每行一個,例如 --env=INPUT_TASK=resolve-channel)"
|
||||
@@ -25,19 +22,28 @@ inputs:
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: checkout
|
||||
if: ${{ inputs.checkout == 'true' }}
|
||||
uses: actions/checkout@v4
|
||||
- name: 偵測
|
||||
id: detect
|
||||
shell: bash
|
||||
run: |
|
||||
[ -f go.mod ] && [ -d test ] && echo "go=true" >> "$GITHUB_OUTPUT" || echo "go=false" >> "$GITHUB_OUTPUT"
|
||||
[ -f Dockerfile ] && echo "docker=true" >> "$GITHUB_OUTPUT" || echo "docker=false" >> "$GITHUB_OUTPUT"
|
||||
- name: shellcheck
|
||||
uses: https://gitea.jsc.idv.tw/actions/shellcheck@${{ vars.ACTION_SHELLCHECK_VERSION }}
|
||||
with:
|
||||
files: ${{ inputs.shellcheck_files }}
|
||||
- name: Go 測試
|
||||
if: ${{ inputs.go_test == 'true' }}
|
||||
if: ${{ steps.detect.outputs.go == 'true' }}
|
||||
uses: https://gitea.jsc.idv.tw/actions/ci-env@${{ vars.ACTION_CI_ENV_VERSION }}
|
||||
env:
|
||||
GO_VERSION: go.mod
|
||||
with:
|
||||
command: ${{ inputs.go_test_command }}
|
||||
- name: 建置映像檔
|
||||
if: ${{ inputs.docker_build == 'true' }}
|
||||
if: ${{ steps.detect.outputs.docker == 'true' }}
|
||||
shell: bash
|
||||
env:
|
||||
RUN_ARGS: ${{ inputs.docker_run_args }}
|
||||
|
||||
Reference in New Issue
Block a user