diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..241567d --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,46 @@ +name: Node.js CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] + + steps: + # Checkout the repository + - uses: actions/checkout@v4 + + # Setup Node.js and cache npm dependencies + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + # Install dependencies cleanly + - name: Install dependencies + run: npm ci + + # Build the project (if a build script exists) + - name: Build project + run: npm run build --if-present + + # Run tests + - name: Run tests + run: npm test + + # Optional check step (if you have a script named "check") + - name: Run checks + run: npm run check || echo "No check script found, skipping." + + # Feedback/logging step + - name: Feedback + run: echo "✅ Node.js ${{ matrix.node-version }}: CI workflow completed successfully."