From 8add2c44de92cf5532a501a9ce398d799eb4563f Mon Sep 17 00:00:00 2001 From: rock Date: Mon, 7 Sep 2026 09:05:25 -0700 Subject: [PATCH] ci: add node.js precheck and conditional install before checkout --- .gitea/actions/checkout-with-node/action.yaml | 30 +++++++++++++++++++ .gitea/workflows/build.yaml | 17 +++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 .gitea/actions/checkout-with-node/action.yaml diff --git a/.gitea/actions/checkout-with-node/action.yaml b/.gitea/actions/checkout-with-node/action.yaml new file mode 100644 index 0000000..0b2366a --- /dev/null +++ b/.gitea/actions/checkout-with-node/action.yaml @@ -0,0 +1,30 @@ +name: Checkout with Node.js +description: "Checkout code and ensure Node.js is installed" + +inputs: + ref: + description: "The branch, tag or SHA to check out" + required: false + default: "" + +runs: + using: composite + steps: + - name: Check and install Node.js if missing + shell: bash + run: | + echo "=== Node.js Installation Check ===" + if command -v node &>/dev/null; then + echo "✓ Node.js already installed: $(node --version)" + else + echo "⚠ Node.js not found, installing..." + apt-get update >/dev/null 2>&1 + apt-get install -y nodejs >/dev/null 2>&1 + echo "✓ Node.js installed: $(node --version)" + fi + echo "✓ npm version: $(npm --version)" + + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 7be7d2a..f28918c 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -17,10 +17,23 @@ jobs: name: CI runs-on: rust steps: - - name: Install Node.js and Docker + - name: Check and install Node.js if missing + shell: bash + run: | + echo "=== Node.js Installation Check ===" + if command -v node &>/dev/null; then + echo "✓ Node.js already installed: $(node --version)" + else + echo "⚠ Node.js not found, installing..." + apt-get update + apt-get install -y nodejs + fi + echo "✓ npm version: $(npm --version)" + + - name: Install Docker run: | apt-get update - apt-get install -y nodejs docker.io + apt-get install -y docker.io - name: Checkout code uses: actions/checkout@v4