commit 1b7bd3926bb89fa8e4c58946fe58b6c8f37d9e24 Author: bot Date: Thu Nov 5 03:16:37 2026 +0000 初始版本 diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..0dfbd6b --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,15 @@ +name: ci +on: + push: + branches: [main] + pull_request: +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true +jobs: + test: + runs-on: docker-ubuntu + steps: + - uses: actions/checkout@v4 + - name: 預設輸入(沒有腳本、不跑測試) + uses: ./ diff --git a/README.md b/README.md new file mode 100644 index 0000000..2c088ed --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# action-ci + +action repo 的共用 CI:先 `shellcheck`,再(可選)在 `ci-env` 容器裡跑 Go 腳本測試(`GO_VERSION=go.mod`,用 go.mod 的版本),最後(可選)`docker build` 檢查映像檔。 + +```yaml +steps: + - uses: actions/checkout@v4 + - uses: https://gitea.jsc.idv.tw/actions/action-ci@v0.0.1 + with: + go_test: true + docker_build: true +``` + +## 輸入 + +|名稱|預設|說明| +|---|---|---| +|`shellcheck_files`|`*.sh`|shellcheck 要檢查的檔案(空白分隔、可用萬用字元),沒有符合的就略過| +|`go_test`|`false`|`true`=跑 Go 測試| +|`go_test_command`|`go vet ./... && go test ./test/`|Go 測試的指令| +|`docker_build`|`false`|`true`=`docker build` 檢查 Dockerfile| + +內部引用的 `shellcheck`、`ci-env` 版本寫死在 `action.yml`,升級要先發它們再發 `action-ci`。 + +圖示:`icon.svg`(頭像用 `icon.png`)。 diff --git a/action-ci.png b/action-ci.png new file mode 100644 index 0000000..6793a4e Binary files /dev/null and b/action-ci.png differ diff --git a/action-ci.svg b/action-ci.svg new file mode 100644 index 0000000..94e9013 --- /dev/null +++ b/action-ci.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..940fb03 --- /dev/null +++ b/action.yml @@ -0,0 +1,33 @@ +name: action-ci +description: "action repo 的共用 CI:shellcheck → Go 腳本測試(在 ci-env 容器裡,Go 版本取 go.mod)→ 建置映像檔。要在 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 建得起來" + default: "false" +runs: + using: composite + steps: + - name: shellcheck + uses: https://gitea.jsc.idv.tw/actions/shellcheck@v0.0.1 + with: + files: ${{ inputs.shellcheck_files }} + - name: Go 測試 + if: ${{ inputs.go_test == 'true' }} + uses: https://gitea.jsc.idv.tw/actions/ci-env@v0.0.2 + env: + GO_VERSION: go.mod + with: + command: ${{ inputs.go_test_command }} + - name: 建置映像檔 + if: ${{ inputs.docker_build == 'true' }} + shell: bash + run: docker build -t "action-test:$GITHUB_SHA" .