@@ -0,0 +1,5 @@
|
||||
.git
|
||||
.gitea
|
||||
test
|
||||
*.md
|
||||
icon.*
|
||||
@@ -0,0 +1,16 @@
|
||||
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
|
||||
- uses: ./
|
||||
with:
|
||||
files: entrypoint.sh
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM ubuntu:24.04
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
# shellcheck 固定 v0.10.0(從官方釋出檔下載,不用 apt 的舊版)
|
||||
RUN apt-get update -qq && apt-get install -y -qq --no-install-recommends ca-certificates curl xz-utils \
|
||||
&& curl -fsSL https://github.com/koalaman/shellcheck/releases/download/v0.10.0/shellcheck-v0.10.0.linux.x86_64.tar.xz | tar -xJ -C /usr/local/bin --strip-components=1 shellcheck-v0.10.0/shellcheck \
|
||||
&& apt-get purge -y -qq curl xz-utils && apt-get autoremove -y -qq && rm -rf /var/lib/apt/lists/*
|
||||
COPY . /action
|
||||
ENTRYPOINT ["/bin/bash", "/action/entrypoint.sh"]
|
||||
@@ -0,0 +1,19 @@
|
||||
# shellcheck
|
||||
|
||||
用 shellcheck(v0.10.0)檢查 shell 腳本的 Docker action,映像檔已內建,不用每次下載。沒有符合的檔案就略過。
|
||||
|
||||
```yaml
|
||||
- uses: https://gitea.jsc.idv.tw/actions/shellcheck@v0.0.1
|
||||
with:
|
||||
files: "*.sh scripts/**/*.sh"
|
||||
severity: warning
|
||||
```
|
||||
|
||||
## 輸入
|
||||
|
||||
|名稱|預設|說明|
|
||||
|---|---|---|
|
||||
|`files`|`*.sh`|要檢查的檔案,空白分隔,可用萬用字元(支援 `**`)|
|
||||
|`severity`|`warning`|回報的最低嚴重度:error、warning、info、style|
|
||||
|
||||
圖示:`icon.svg`(頭像用 `icon.png`)。
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
name: shellcheck
|
||||
description: "用 shellcheck 檢查 shell 腳本(Docker action,shellcheck v0.10.0)。沒有符合的檔案就略過。要在 checkout 之後使用"
|
||||
inputs:
|
||||
files:
|
||||
description: "要檢查的檔案,空白分隔,可用萬用字元(相對於儲存庫根目錄,支援 **)"
|
||||
default: "*.sh"
|
||||
severity:
|
||||
description: "回報的最低嚴重度:error、warning、info、style"
|
||||
default: warning
|
||||
runs:
|
||||
using: docker
|
||||
image: Dockerfile
|
||||
args:
|
||||
- ${{ inputs.files }}
|
||||
- ${{ inputs.severity }}
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# 用法:entrypoint.sh <files> <severity>;files 是空白分隔的路徑或萬用字元(相對於 workspace),沒有符合的檔案就略過
|
||||
set -euo pipefail
|
||||
cd "${GITHUB_WORKSPACE:-$PWD}"
|
||||
shopt -s nullglob globstar
|
||||
# shellcheck disable=SC2206 # 依空白拆開,並由 shell 展開萬用字元(不符合的萬用字元展開成空)
|
||||
files=(${1:-*.sh})
|
||||
if [ ${#files[@]} -eq 0 ]; then
|
||||
echo "沒有符合「${1:-*.sh}」的檔案,略過 shellcheck"
|
||||
exit 0
|
||||
fi
|
||||
echo "shellcheck(嚴重度 ${2:-warning} 以上):${files[*]}"
|
||||
exec shellcheck -x -S "${2:-warning}" "${files[@]}"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 21 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="#ca8a04"/><circle fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" cx="226" cy="226" r="110"/><path fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" d="M306 306l100 100"/><path fill="none" stroke="#fff" stroke-width="28" stroke-linecap="round" stroke-linejoin="round" d="M176 228l36 36 62-72"/></svg>
|
||||
|
After Width: | Height: | Size: 517 B |
Reference in New Issue
Block a user