47 lines
2.0 KiB
YAML
47 lines
2.0 KiB
YAML
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 之後使用,各步驟用輸入開關"
|
||
inputs:
|
||
shellcheck_files:
|
||
description: "shellcheck 要檢查的檔案(空白分隔,可用萬用字元);沒有符合的檔案就略過"
|
||
default: "*.sh"
|
||
go_test:
|
||
description: "true=跑 Go 測試"
|
||
default: "false"
|
||
go_test_command:
|
||
description: "go_test 為 true 時執行的指令"
|
||
default: "go vet ./... && go test ./test/"
|
||
docker_build:
|
||
description: "true=用 docker build 檢查 Dockerfile 建得起來(映像檔標籤唯一,不會撞到 runner 上的舊映像檔)"
|
||
default: "false"
|
||
docker_run_args:
|
||
description: "docker_build 之後實際執行容器的參數(entrypoint 的參數,每行一個);空=不執行"
|
||
default: ""
|
||
docker_run_options:
|
||
description: "執行容器的 docker create 選項(每行一個,例如 --env=INPUT_TASK=resolve-channel)"
|
||
default: ""
|
||
docker_run_expect:
|
||
description: "容器輸出必須包含的字串;空=只檢查結束碼"
|
||
default: ""
|
||
runs:
|
||
using: composite
|
||
steps:
|
||
- 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' }}
|
||
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' }}
|
||
shell: bash
|
||
env:
|
||
RUN_ARGS: ${{ inputs.docker_run_args }}
|
||
RUN_OPTIONS: ${{ inputs.docker_run_options }}
|
||
RUN_EXPECT: ${{ inputs.docker_run_expect }}
|
||
run: bash "${{ github.action_path }}/docker-check.sh"
|