Add CI for markdown and yaml #1
95
.gitea/workflows/ci.yml
Normal file
95
.gitea/workflows/ci.yml
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
skip-ci-check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
should_skip: ${{ steps.check.outputs.skip }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout (for commit message)
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Skip check (@skipci in branch name or commit message)
|
||||||
|
id: check
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SKIP_PATTERN='@skipci'
|
||||||
|
|
||||||
|
# Branch name (works for push and PR on GitHub-compatible runners)
|
||||||
|
BRANCH_NAME="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
|
||||||
|
|
||||||
|
# Commit message (best-effort; fall back to git)
|
||||||
|
COMMIT_MSG="${GITHUB_EVENT_HEAD_COMMIT_MESSAGE:-}"
|
||||||
|
if [ -z "${COMMIT_MSG}" ]; then
|
||||||
|
COMMIT_MSG="$(git log -1 --pretty=%B 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SKIP=0
|
||||||
|
if echo "${BRANCH_NAME}" | grep -qiF "${SKIP_PATTERN}"; then
|
||||||
|
echo "Skipping CI: branch name contains ${SKIP_PATTERN}"
|
||||||
|
SKIP=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${SKIP}" -eq 0 ] && [ -n "${COMMIT_MSG}" ]; then
|
||||||
|
if echo "${COMMIT_MSG}" | grep -qiF "${SKIP_PATTERN}"; then
|
||||||
|
echo "Skipping CI: commit message contains ${SKIP_PATTERN}"
|
||||||
|
SKIP=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "skip=${SKIP}" >> "${GITHUB_OUTPUT}"
|
||||||
|
echo "Branch: ${BRANCH_NAME}"
|
||||||
|
echo "Skip CI: ${SKIP}"
|
||||||
|
|
||||||
|
markdown-lint:
|
||||||
|
needs: skip-ci-check
|
||||||
|
if: needs.skip-ci-check.outputs.should_skip != '1'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install markdownlint-cli2
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
npm install -g markdownlint-cli2@0.14.0
|
||||||
|
|
||||||
|
- name: Lint markdown
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# Lint tracked markdown files only (avoid linting generated/vendor content)
|
||||||
|
git ls-files '*.md' | xargs -r markdownlint-cli2
|
||||||
|
|
||||||
|
yaml-validate:
|
||||||
|
needs: skip-ci-check
|
||||||
|
if: needs.skip-ci-check.outputs.should_skip != '1'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install yamllint
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
python3 -m pip install --user --no-cache-dir yamllint==1.35.1
|
||||||
|
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
|
- name: Lint YAML
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# Lint tracked YAML only (avoid .git and other noise)
|
||||||
|
git ls-files '*.yml' '*.yaml' | xargs -r yamllint -d "{extends: default, rules: {line-length: disable}}"
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user