All checks were successful
Test Action / Test Node (pull_request) Successful in 17s
Test Action / Test nginx (pull_request) Successful in 21s
Test Action / Test Custom Server Path (pull_request) Successful in 25s
Test Action / Test Build Command (pull_request) Successful in 25s
Test Action / Test PHP (pull_request) Successful in 1m15s
Test Action / Test All Components (pull_request) Successful in 1m21s
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
241 lines
7.8 KiB
YAML
241 lines
7.8 KiB
YAML
name: 'Nodarx Server Install Action'
|
|
description: 'Clone Nodarx server repository and install Node.js, PHP, and/or nginx based on test requirements'
|
|
author: 'Nodarx'
|
|
|
|
branding:
|
|
icon: 'server'
|
|
color: 'blue'
|
|
|
|
inputs:
|
|
server-path:
|
|
description: 'Path where the server will be cloned/installed'
|
|
required: false
|
|
default: './server'
|
|
install-node:
|
|
description: 'Install Node.js environment'
|
|
required: false
|
|
default: 'false'
|
|
install-php:
|
|
description: 'Install PHP environment'
|
|
required: false
|
|
default: 'false'
|
|
install-nginx:
|
|
description: 'Install nginx web server'
|
|
required: false
|
|
default: 'false'
|
|
install-dependencies:
|
|
description: 'Whether to install dependencies (npm/composer)'
|
|
required: false
|
|
default: 'true'
|
|
node-version:
|
|
description: 'Node.js version to use (if install-node is true)'
|
|
required: false
|
|
default: '24'
|
|
php-version:
|
|
description: 'PHP version to use (if install-php is true)'
|
|
required: false
|
|
default: '8.5'
|
|
php-extensions:
|
|
description: 'Comma-separated list of PHP extensions to install'
|
|
required: false
|
|
default: 'mbstring, xml, ctype, json, curl, zip'
|
|
nginx-config:
|
|
description: 'Path to nginx configuration file (optional)'
|
|
required: false
|
|
default: ''
|
|
build-command:
|
|
description: 'Custom build command to run after install'
|
|
required: false
|
|
default: ''
|
|
post-install-script:
|
|
description: 'Custom script to run after installation'
|
|
required: false
|
|
default: ''
|
|
server-repository:
|
|
description: 'Repository to checkout for the server source'
|
|
required: false
|
|
default: 'Nodarx/server'
|
|
server-ref:
|
|
description: 'Branch, tag, or SHA to checkout for the server repository'
|
|
required: false
|
|
default: 'main'
|
|
github-server-url:
|
|
description: 'Git server base URL for checkout (e.g. https://git.ktrix.dev)'
|
|
required: false
|
|
default: 'https://git.ktrix.dev'
|
|
checkout-token:
|
|
description: 'Optional token for private/external repository checkout'
|
|
required: false
|
|
default: ''
|
|
|
|
outputs:
|
|
install-status:
|
|
description: 'Status of the installation (success/failure)'
|
|
value: ${{ steps.install.outputs.status }}
|
|
install-path:
|
|
description: 'Path where the server was installed'
|
|
value: ${{ steps.install.outputs.path }}
|
|
node-installed:
|
|
description: 'Whether Node.js was installed'
|
|
value: ${{ steps.install.outputs.node_installed }}
|
|
php-installed:
|
|
description: 'Whether PHP was installed'
|
|
value: ${{ steps.install.outputs.php_installed }}
|
|
nginx-installed:
|
|
description: 'Whether nginx was installed'
|
|
value: ${{ steps.install.outputs.nginx_installed }}
|
|
|
|
runs:
|
|
using: 'composite'
|
|
steps:
|
|
- name: Validate inputs
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Validating inputs"
|
|
|
|
# Validate at least one component is enabled
|
|
if [ "${{ inputs.install-node }}" != "true" ] && \
|
|
[ "${{ inputs.install-php }}" != "true" ] && \
|
|
[ "${{ inputs.install-nginx }}" != "true" ]; then
|
|
echo "::error::At least one component must be enabled (install-node, install-php, or install-nginx)"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Server path: ${{ inputs.server-path }}"
|
|
echo "Components to install:"
|
|
[ "${{ inputs.install-node }}" == "true" ] && echo " ✓ Node.js ${{ inputs.node-version }}"
|
|
[ "${{ inputs.install-php }}" == "true" ] && echo " ✓ PHP ${{ inputs.php-version }}"
|
|
[ "${{ inputs.install-nginx }}" == "true" ] && echo " ✓ nginx"
|
|
echo "Install dependencies: ${{ inputs.install-dependencies }}"
|
|
echo "::endgroup::"
|
|
|
|
- name: Checkout server repository (public/no token)
|
|
if: inputs.checkout-token == ''
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ inputs.server-repository }}
|
|
ref: ${{ inputs.server-ref }}
|
|
path: ${{ inputs.server-path }}
|
|
fetch-depth: 1
|
|
submodules: recursive
|
|
github-server-url: ${{ inputs.github-server-url }}
|
|
|
|
- name: Checkout server repository (with token)
|
|
if: inputs.checkout-token != ''
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ inputs.server-repository }}
|
|
ref: ${{ inputs.server-ref }}
|
|
path: ${{ inputs.server-path }}
|
|
fetch-depth: 1
|
|
submodules: recursive
|
|
github-server-url: ${{ inputs.github-server-url }}
|
|
token: ${{ inputs.checkout-token }}
|
|
|
|
- name: Setup Node
|
|
if: inputs.install-node == 'true'
|
|
uses: actions/setup-node@v6.2.0
|
|
with:
|
|
node-version: ${{ inputs.node-version }}
|
|
|
|
- name: Setup PHP
|
|
if: inputs.install-php == 'true'
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ inputs.php-version }}
|
|
extensions: ${{ inputs.php-extensions }}
|
|
tools: composer:v2
|
|
coverage: none
|
|
|
|
- name: Install nginx
|
|
if: inputs.install-nginx == 'true'
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Installing nginx"
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y nginx
|
|
echo "✓ nginx installed successfully"
|
|
nginx -v
|
|
echo "::endgroup::"
|
|
|
|
- name: Configure nginx
|
|
if: inputs.install-nginx == 'true' && inputs.nginx-config != ''
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Configuring nginx"
|
|
|
|
if [ -f "${{ inputs.nginx-config }}" ]; then
|
|
sudo cp "${{ inputs.nginx-config }}" /etc/nginx/sites-available/default
|
|
sudo nginx -t
|
|
echo "✓ nginx configured successfully"
|
|
else
|
|
echo "::warning::nginx config file not found: ${{ inputs.nginx-config }}"
|
|
fi
|
|
|
|
echo "::endgroup::"
|
|
|
|
- name: Start nginx
|
|
if: inputs.install-nginx == 'true'
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Starting nginx"
|
|
sudo nginx || echo "nginx may already be running"
|
|
# Verify nginx is working
|
|
if sudo nginx -t 2>/dev/null; then
|
|
echo "✓ nginx configuration valid"
|
|
fi
|
|
if pgrep nginx >/dev/null; then
|
|
echo "✓ nginx is running"
|
|
fi
|
|
echo "✓ nginx started successfully"
|
|
echo "::endgroup::"
|
|
|
|
- name: Install Node dependencies
|
|
if: inputs.install-node == 'true' && inputs.install-dependencies == 'true'
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Installing Node dependencies"
|
|
cd "${{ inputs.server-path }}"
|
|
npm ci || npm install
|
|
echo "✓ Node dependencies installed successfully"
|
|
echo "::endgroup::"
|
|
|
|
- name: Install PHP dependencies
|
|
if: inputs.install-php == 'true' && inputs.install-dependencies == 'true'
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Installing PHP dependencies"
|
|
cd "${{ inputs.server-path }}"
|
|
composer install --optimize-autoloader
|
|
echo "✓ PHP dependencies installed successfully"
|
|
echo "::endgroup::"
|
|
|
|
- name: Run build command
|
|
if: inputs.build-command != ''
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Running build command"
|
|
cd "${{ inputs.server-path }}"
|
|
${{ inputs.build-command }}
|
|
echo "::endgroup::"
|
|
|
|
- name: Run post-install script
|
|
if: inputs.post-install-script != ''
|
|
shell: bash
|
|
run: |
|
|
echo "::group::Running post-install script"
|
|
cd "${{ inputs.server-path }}"
|
|
chmod +x "${{ inputs.post-install-script }}"
|
|
"${{ inputs.post-install-script }}"
|
|
echo "::endgroup::"
|
|
|
|
- name: Set outputs
|
|
id: install
|
|
shell: bash
|
|
run: |
|
|
echo "status=success" >> $GITHUB_OUTPUT
|
|
echo "path=${{ inputs.server-path }}" >> $GITHUB_OUTPUT
|
|
echo "node_installed=${{ inputs.install-node }}" >> $GITHUB_OUTPUT
|
|
echo "php_installed=${{ inputs.install-php }}" >> $GITHUB_OUTPUT
|
|
echo "nginx_installed=${{ inputs.install-nginx }}" >> $GITHUB_OUTPUT
|