Files
action-server-install/action.yml
T
Sebastian 59a23662b9
Test Action / Test Node (pull_request) Has been cancelled
Test Action / Test PHP (pull_request) Has been cancelled
Test Action / Test Database Configuration (pull_request) Has been cancelled
Test Action / Test Base Modules Installation (pull_request) Has been cancelled
Test Action / Test Base Modules Requires PHP (pull_request) Has been cancelled
Test Action / Test nginx (pull_request) Has been cancelled
Test Action / Test All Components (pull_request) Has been cancelled
Test Action / Test Custom Server Path (pull_request) Has been cancelled
Test Action / Test Build Command (pull_request) Has been cancelled
fix: test hang
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
2026-07-23 00:37:12 -04:00

338 lines
12 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: ''
database-uri:
description: 'MongoDB connection URI to write into config/system.php (requires install-php; leave empty to keep the repository default)'
required: false
default: ''
database-name:
description: 'MongoDB database name to write into config/system.php (requires install-php; leave empty to keep the repository default)'
required: false
default: ''
app-environment:
description: 'Application environment to write into config/system.php, e.g. "test" (requires install-php; leave empty to keep the repository default)'
required: false
default: ''
security-salt:
description: 'Security salt to write into config/system.php (requires install-php; leave empty to keep the repository default)'
required: false
default: ''
install-base-modules:
description: 'Clone, install, and enable the base module set (currently: authentication_provider_password). Requires install-php and a reachable, configured database.'
required: false
default: 'false'
base-modules-repository:
description: 'Repository URL for the base password authentication provider module (used when install-base-modules is true)'
required: false
default: 'https://git.ktrix.dev/Nodarx/authentication_provider_password'
base-modules-branch:
description: 'Branch, tag, or commit to check out for the base password authentication provider module'
required: false
default: 'main'
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 }}
base-modules-installed:
description: 'Whether the base module set was installed'
value: ${{ steps.install.outputs.base_modules_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
# install-base-modules requires PHP (it runs bin/console)
if [ "${{ inputs.install-base-modules }}" == "true" ] && [ "${{ inputs.install-php }}" != "true" ]; then
echo "::error::install-base-modules requires install-php to be 'true'"
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 }}
persist-credentials: false
- 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 }}
persist-credentials: false
- 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: Configure server settings
if: inputs.install-php == 'true'
shell: bash
env:
DATABASE_URI: ${{ inputs.database-uri }}
DATABASE_NAME: ${{ inputs.database-name }}
APP_ENVIRONMENT: ${{ inputs.app-environment }}
SECURITY_SALT: ${{ inputs.security-salt }}
run: |
echo "::group::Configuring server settings"
if [ -z "$DATABASE_URI$DATABASE_NAME$APP_ENVIRONMENT$SECURITY_SALT" ]; then
echo "No configuration overrides provided, keeping repository defaults."
else
php "${{ github.action_path }}/scripts/configure-server.php" "${{ inputs.server-path }}/config/system.php"
fi
echo "::endgroup::"
- 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: Clone base modules
if: inputs.install-base-modules == 'true'
shell: bash
env:
MODULE_REPOSITORY: ${{ inputs.base-modules-repository }}
MODULE_REF: ${{ inputs.base-modules-branch }}
MODULE_PATH: ${{ inputs.server-path }}/modules/authentication_provider_password
run: |
echo "::group::Cloning base modules"
if [ -e "$MODULE_PATH" ]; then
echo "::error::Base module path already exists: $MODULE_PATH"
exit 1
fi
mkdir -p "$(dirname "$MODULE_PATH")"
git init "$MODULE_PATH"
git -C "$MODULE_PATH" remote add origin "$MODULE_REPOSITORY"
git -C "$MODULE_PATH" fetch --depth 1 origin "$MODULE_REF"
git -C "$MODULE_PATH" checkout --detach FETCH_HEAD
echo "✓ Base modules cloned"
echo "::endgroup::"
- name: Install and enable base modules
if: inputs.install-base-modules == 'true'
shell: bash
run: |
echo "::group::Installing base modules"
cd "${{ inputs.server-path }}"
echo "Installing authentication_provider_password..."
php bin/console module:install authentication_provider_password
php bin/console module:enable authentication_provider_password
echo "✓ Base modules installed"
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
echo "base_modules_installed=${{ inputs.install-base-modules }}" >> $GITHUB_OUTPUT