Sebastian Krupinski 07ec832837
Some checks failed
Test Action / Test Without Dependencies (pull_request) Successful in 10s
Test Action / Test Node (pull_request) Successful in 22s
Test Action / Test Custom Server Path (pull_request) Successful in 19s
Test Action / Test nginx (pull_request) Failing after 36s
Test Action / Test Build Command (pull_request) Successful in 20s
Test Action / Test PHP (pull_request) Failing after 1m17s
Test Action / Test All Components (pull_request) Failing after 1m15s
chore: update name
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-02-14 16:49:14 -05:00
2026-02-14 16:49:14 -05:00
2026-02-14 16:28:51 -05:00
2026-02-14 16:28:51 -05:00
2026-02-14 16:28:51 -05:00
2026-02-14 16:49:14 -05:00
2026-02-14 16:28:51 -05:00
2026-02-14 16:28:51 -05:00
2026-02-14 16:28:51 -05:00

Server Install Action

A GitHub Action to clone the Nodarx server repository and install Node.js, PHP, and/or nginx based on test requirements. Perfect for creating lean test environments (e.g., JS tests install only Node) while supporting full integration tests with all components.

Features

  • Clone Nodarx server repository with submodule support
  • Flexible component installation (Node.js, PHP, nginx)
  • Support for multiple Node.js package managers (npm, yarn, pnpm)
  • Automatic dependency installation (npm, composer)
  • Environment file configuration
  • Custom build commands
  • Post-installation scripts
  • Comprehensive error handling and logging

Usage

Node.js Only (Unit Tests)

name: Node.js Unit Tests
on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Install Server with Node.js
        uses: Nodarx/action-server-install@v2
        with:
          install-node: 'true'
          node-version: '20'
          package-manager: 'npm'
      
      - name: Run tests
        run: |
          cd server
          npm test

PHP Only (Unit Tests)

name: PHP Unit Tests
on: [push]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Install Server with PHP
        uses: Nodarx/action-server-install@v2
        with:
          install-php: 'true'
          php-version: '8.2'
      
      - name: Run tests
        run: |
          cd server
          ./vendor/bin/phpunit

Full Integration Test (All Components)

name: Integration Tests
on: [push]

jobs:
  integration:
    runs-on: ubuntu-latest
    steps:
      - name: Install Server with All Components
        uses: Nodarx/action-server-install@v2
        with:
          install-node: 'true'
          install-php: 'true'
          install-nginx: 'true'
          node-version: '20'
          php-version: '8.2'
      
      - name: Run integration tests
        run: |
          cd server
          npm run test:integration

With Custom nginx Configuration

- name: Install Server with nginx
  uses: Nodarx/action-server-install@v2
  with:
    install-nginx: 'true'
    nginx-config: './config/nginx.conf'

Advanced Example with All Options

name: Deploy Server
on: [push]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Create environment file
        run: |
          echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" > .env.production
          echo "API_KEY=${{ secrets.API_KEY }}" >> .env.production
      
      - name: Install Server
        uses: Nodarx/action-server-install@v2
        with:
          server-path: './server'
          install-node: 'true'
          install-php: 'true'
          install-nginx: 'true'
          node-version: '20'
          package-manager: 'pnpm'
          php-version: '8.2'
          php-extensions: 'mbstring, xml, ctype, json, curl, zip, pdo, pdo_mysql'
          nginx-config: './config/nginx.conf'
          install-dependencies: 'true'
          build-command: 'npm run build'
          env-file: '.env.production'
          post-install-script: './scripts/post-install.sh'

Inputs

Component Selection

Input Description Required Default
install-node Install Node.js environment No false
install-php Install PHP environment No false
install-nginx Install nginx web server No false

Note: At least one component must be enabled.

General Configuration

Input Description Required Default
server-path Path where the server will be cloned/installed No ./server
install-dependencies Whether to install dependencies (npm/composer) No true
build-command Custom build command to run after install No ''
env-file Path to environment file to copy (.env) No ''
post-install-script Custom script to run after installation No ''

Node.js Configuration

Input Description Required Default
node-version Node.js version to use No 20
package-manager Package manager for Node.js (npm, yarn, pnpm) No npm

PHP Configuration

Input Description Required Default
php-version PHP version to use No 8.2
php-extensions Comma-separated list of PHP extensions to install No mbstring, xml, ctype, json, curl, zip

nginx Configuration

Input Description Required Default
nginx-config Path to nginx configuration file No ''

Outputs

Output Description
install-status Status of the installation (success/failure)
install-path Path where the server was installed
node-installed Whether Node.js was installed (true/false)
php-installed Whether PHP was installed (true/false)
nginx-installed Whether nginx was installed (true/false)

Component Details

Server Repository

  • Clones from: https://git.ktrix.dev/Nodarx/server
  • Includes recursive submodule initialization
  • Updates existing directory if already present

Node.js

  • Uses actions/setup-node@v4 for Node.js setup
  • npm: Uses npm ci (with fallback to npm install)
  • yarn: Uses yarn install --frozen-lockfile (with fallback)
  • pnpm: Uses pnpm install --frozen-lockfile (with fallback, requires pnpm/action-setup)
  • Default version: Node.js 20 (LTS)

PHP

  • Uses shivammathur/setup-php@v2 for PHP setup
  • Default version: PHP 8.2
  • Default extensions: mbstring, xml, ctype, json, curl, zip
  • composer: Uses composer install --no-dev --optimize-autoloader
  • Skips gracefully if no composer.json found

nginx

  • Installs via system package manager (apt-get)
  • Supports optional custom configuration file
  • Automatically starts the nginx service
  • Validates configuration before reload

Best Practices

  1. Enable only needed components: For faster test runs

    # JS unit tests - Node.js only
    - uses: Nodarx/action-server-install@v2
      with:
        install-node: 'true'
    
  2. Pin to specific versions: Use commit SHA or version tag

    uses: Nodarx/action-server-install@v2.0.0
    
  3. Cache dependencies: Combine with caching for faster builds

    - uses: actions/cache@v4
      with:
        path: ~/.npm
        key: ${{ runner.os }}-node-${{ hashFiles('server/package-lock.json') }}
    
    - uses: Nodarx/action-server-install@v2
      with:
        install-node: 'true'
    
  4. Secure secrets: Use GitHub Secrets for sensitive variables

    - name: Create .env file
      run: |
        echo "API_KEY=${{ secrets.API_KEY }}" > .env.production
    
    - uses: Nodarx/action-server-install@v2
      with:
        install-node: 'true'
        env-file: '.env.production'
    
  5. Test different component combinations: Matrix testing

    strategy:
      matrix:
        include:
          - name: Node Tests
            install-node: 'true'
            install-php: 'false'
          - name: PHP Tests
            install-node: 'false'
            install-php: 'true'
          - name: Integration Tests
            install-node: 'true'
            install-php: 'true'
    

Development

Local Testing

To test this action locally, you can use act:

act -j test -W .github/workflows/test.yml

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Versioning

This action follows Semantic Versioning. For the versions available, see the tags on this repository.

Major Version Tags

Major version tags (v1, v2, etc.) are maintained to point to the latest minor/patch release within that major version:

uses: Nodarx/action-server-install@v1  # always latest v1.x.x
uses: Nodarx/action-server-install@v1.2  # always latest v1.2.x
uses: Nodarx/action-server-install@v1.2.3  # exact version

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

If you encounter any issues or have questions:

Acknowledgments

  • Inspired by GitHub's official actions
  • Built with the GitHub Actions community
Description
No description provided
Readme MIT 70 KiB
Languages
Shell 100%