ci: add node.js precheck and conditional install before checkout
This commit is contained in:
@@ -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 }}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user