From eb7a949eaca6c40666b6b5878dc600d6fb5f5af5 Mon Sep 17 00:00:00 2001 From: supeisen <570779284@qq.com> Date: Mon, 6 Apr 2026 15:59:09 +0800 Subject: [PATCH] Generalize template CI for standard actions --- .gitea/workflows/ci.yml | 53 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index cf0c4ec..a75b9ec 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -12,7 +12,57 @@ jobs: runs-on: linux-amd64 steps: - name: Checkout repository - uses: http://debian.hellosu.top:3000/actions/checkout@v4 + uses: actions/checkout@v4 + + - name: Detect project files + id: detect + run: | + if [ -f package.json ]; then + echo "node=true" >> "$GITHUB_OUTPUT" + else + echo "node=false" >> "$GITHUB_OUTPUT" + fi + + if [ -f pyproject.toml ] || [ -f requirements.txt ]; then + echo "python=true" >> "$GITHUB_OUTPUT" + else + echo "python=false" >> "$GITHUB_OUTPUT" + fi + + - name: Setup Node.js + if: steps.detect.outputs.node == 'true' + uses: actions/setup-node@v4 + with: + node-version: 24 + + - name: Install Node.js dependencies + if: steps.detect.outputs.node == 'true' + run: | + if [ -f package-lock.json ]; then + npm ci --ignore-scripts + else + npm install --ignore-scripts + fi + + - name: Lint Node.js project + if: steps.detect.outputs.node == 'true' + run: npm run lint --if-present + + - name: Build Node.js project + if: steps.detect.outputs.node == 'true' + run: npm run build --if-present + + - name: Setup Python + if: steps.detect.outputs.python == 'true' + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Show Python environment + if: steps.detect.outputs.python == 'true' + run: | + python --version + python -m pip --version - name: Show workspace run: | @@ -24,6 +74,5 @@ jobs: - name: Validate template files run: | - test -f README.md test -f .editorconfig test -f .gitea/workflows/ci.yml