Files

22 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Static checks on the workflow. This is NOT a runner: it proves the YAML parses and that every
# command the workflow runs is one the other scripts executed. It cannot prove Gitea accepts it.
source "$(dirname "$0")/lib.sh"
{
banner "Parse .gitea/workflows/ci.yaml"
python3 - <<'PY'
import yaml
w = yaml.safe_load(open(".gitea/workflows/ci.yaml"))
print("name :", w["name"])
print("triggers :", list(w[True].keys()) if True in w else list(w["on"].keys()))
for j, d in w["jobs"].items():
print(f"job {j:6s}: runs-on={d['runs-on']} needs={d.get('needs','-')} steps={len(d['steps'])}")
for s in d["steps"]:
print(" -", s.get("uses") or s.get("name") or "run")
PY
banner "Secrets are only ever referenced through env:, never inside a run: line"
if grep -nE '^\s+(run|-).*\$\{\{ *secrets\.' .gitea/workflows/ci.yaml | grep -v 'env:' | grep -E 'run:|mvn|curl'; then echo "FOUND inline secret"; else echo "ok: no secret interpolated into a shell command"; fi
banner "Secret names obey Gitea's rules (no GITHUB_/GITEA_ prefix)"
grep -oE 'secrets\.[A-Za-z0-9_]+' .gitea/workflows/ci.yaml | sort -u
} 2>&1 | tee "$OUT/07-workflow-lint.txt"