@@ -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: ./
|
||||
@@ -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`)。
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512"><rect width="512" height="512" rx="104" fill="#475569"/><rect fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" x="120" y="104" width="272" height="332" rx="30"/><path fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" d="M206 104V84h100v20"/><path fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" d="M170 214l26 26 46-52M170 330l26 26 46-52"/><path fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" d="M290 214h56M290 330h56"/></svg>
|
||||
|
After Width: | Height: | Size: 685 B |
+33
@@ -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" .
|
||||
Reference in New Issue
Block a user