Compare commits
1 Commits
main
..
8c5570bddd
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c5570bddd |
@@ -13,7 +13,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6.0.2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
+55
-146
@@ -5,34 +5,20 @@ on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
# Keep the fixture source in one place. Override these with repository variables
|
||||
# when testing another server repository; no workflow edits are required.
|
||||
env:
|
||||
TEST_SERVER_REPOSITORY: ${{ vars.TEST_SERVER_REPOSITORY || 'Nodarx/server' }}
|
||||
TEST_SERVER_REF: ${{ vars.TEST_SERVER_REF || 'main' }}
|
||||
TEST_GIT_SERVER_URL: ${{ vars.TEST_GIT_SERVER_URL || 'https://git.ktrix.dev' }}
|
||||
TEST_DATABASE_URI: ${{ vars.TEST_DATABASE_URI || 'mongodb://mongo:27017/?tls=false' }}
|
||||
|
||||
jobs:
|
||||
test-node:
|
||||
name: Test Node
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with Node.js (npm)
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-node: 'true'
|
||||
node-version: '24'
|
||||
package-manager: 'npm'
|
||||
server-path: './test-server'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
@@ -40,29 +26,25 @@ jobs:
|
||||
test -d ./test-server/node_modules || exit 1
|
||||
chmod +x ./scripts/health-check.sh
|
||||
./scripts/health-check.sh ./test-server true false false
|
||||
test "${{ steps.install.outputs.install-status }}" = "success"
|
||||
test "${{ steps.install.outputs.node-installed }}" = "true"
|
||||
echo "✓ Node.js (npm) installation successful"
|
||||
|
||||
- name: Run server tests
|
||||
run: |
|
||||
cd ./test-server
|
||||
npm run test:unit
|
||||
|
||||
test-php:
|
||||
name: Test PHP
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with PHP
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-php: 'true'
|
||||
php-version: '8.5'
|
||||
server-path: './test-server'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
@@ -71,113 +53,24 @@ jobs:
|
||||
composer --version
|
||||
chmod +x ./scripts/health-check.sh
|
||||
./scripts/health-check.sh ./test-server false true false
|
||||
test "${{ steps.install.outputs.install-status }}" = "success"
|
||||
test "${{ steps.install.outputs.php-installed }}" = "true"
|
||||
echo "✓ PHP installation successful"
|
||||
|
||||
test-database-config:
|
||||
name: Test Database Configuration
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with database configuration
|
||||
uses: ./
|
||||
with:
|
||||
install-php: 'true'
|
||||
php-version: '8.5'
|
||||
server-path: './test-server'
|
||||
database-uri: ${{ env.TEST_DATABASE_URI }}
|
||||
database-name: 'ktrix_ci'
|
||||
app-environment: 'test'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify configuration was written
|
||||
|
||||
- name: Run server tests
|
||||
run: |
|
||||
cd ./test-server
|
||||
php -r '
|
||||
$config = include "config/system.php";
|
||||
$uri = $config["database"]["uri"] ?? null;
|
||||
$name = $config["database"]["database"] ?? null;
|
||||
$env = $config["environment"] ?? null;
|
||||
$expectedUri = getenv("TEST_DATABASE_URI");
|
||||
if ($uri !== $expectedUri) { fwrite(STDERR, "database.uri not overridden, got: $uri\n"); exit(1); }
|
||||
if ($name !== "ktrix_ci") { fwrite(STDERR, "database.database not overridden, got: $name\n"); exit(1); }
|
||||
if ($env !== "test") { fwrite(STDERR, "environment not overridden, got: $env\n"); exit(1); }
|
||||
'
|
||||
echo "✓ Database configuration verified"
|
||||
|
||||
test-base-modules:
|
||||
name: Test Base Modules Installation
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:7
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with base modules
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-php: 'true'
|
||||
php-version: '8.5'
|
||||
server-path: './test-server'
|
||||
database-uri: ${{ env.TEST_DATABASE_URI }}
|
||||
database-name: 'ktrix_ci'
|
||||
install-base-modules: 'true'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify password authentication provider is installed and enabled
|
||||
run: |
|
||||
test -d ./test-server/modules/authentication_provider_password
|
||||
test "${{ steps.install.outputs.install-status }}" = "success"
|
||||
test "${{ steps.install.outputs.base-modules-installed }}" = "true"
|
||||
echo "✓ authentication_provider_password is installed and enabled"
|
||||
|
||||
test-base-modules-requires-php:
|
||||
name: Test Base Modules Requires PHP
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Verify base modules require PHP
|
||||
run: |
|
||||
if bash ./scripts/validate-inputs.sh true false false true; then
|
||||
echo "::error::Expected validation to fail when install-base-modules is set without install-php"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Validation correctly rejected install-base-modules without install-php"
|
||||
composer test:unit
|
||||
|
||||
test-nginx:
|
||||
name: Test nginx
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with nginx
|
||||
uses: ./
|
||||
with:
|
||||
install-nginx: 'true'
|
||||
server-path: './test-server'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
@@ -194,11 +87,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with all components
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-node: 'true'
|
||||
@@ -206,11 +96,8 @@ jobs:
|
||||
install-nginx: 'true'
|
||||
node-version: '24'
|
||||
php-version: '8.5'
|
||||
package-manager: 'npm'
|
||||
server-path: './test-server'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
@@ -223,46 +110,73 @@ jobs:
|
||||
nginx -v
|
||||
chmod +x ./scripts/health-check.sh
|
||||
./scripts/health-check.sh ./test-server true true true
|
||||
test "${{ steps.install.outputs.install-status }}" = "success"
|
||||
test "${{ steps.install.outputs.node-installed }}" = "true"
|
||||
test "${{ steps.install.outputs.php-installed }}" = "true"
|
||||
test "${{ steps.install.outputs.nginx-installed }}" = "true"
|
||||
echo "✓ All components installation successful"
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
cd ./test-server
|
||||
if [ -f package.json ] && grep -q '"test:integration"' package.json; then
|
||||
npm run test:integration
|
||||
else
|
||||
echo "⚠ No integration test script configured, skipping"
|
||||
fi
|
||||
|
||||
test-custom-paths:
|
||||
name: Test Custom Server Path
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with custom path
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-node: 'true'
|
||||
server-path: './my-custom-server'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
test -d ./my-custom-server || exit 1
|
||||
test -d ./my-custom-server/node_modules || exit 1
|
||||
test "${{ steps.install.outputs.install-path }}" = "./my-custom-server"
|
||||
test "${{ steps.install.outputs.install-status }}" = "success"
|
||||
echo "✓ Custom path installation successful"
|
||||
|
||||
- name: Run server tests
|
||||
run: |
|
||||
cd ./my-custom-server
|
||||
if [ -f package.json ] && grep -q '"test"' package.json; then
|
||||
npm test
|
||||
else
|
||||
echo "⚠ No test script configured, skipping"
|
||||
fi
|
||||
|
||||
test-without-dependencies:
|
||||
name: Test Without Dependencies
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Test action without installing dependencies
|
||||
uses: ./
|
||||
with:
|
||||
install-node: 'true'
|
||||
install-dependencies: 'false'
|
||||
server-path: './test-server'
|
||||
|
||||
- name: Verify installation
|
||||
run: |
|
||||
test -d ./test-server || exit 1
|
||||
node --version
|
||||
# node_modules should not exist since we skipped dependency installation
|
||||
if [ -d ./test-server/node_modules ]; then
|
||||
echo "✗ Dependencies were installed when they shouldn't have been"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Installation without dependencies successful"
|
||||
|
||||
test-build-command:
|
||||
name: Test Build Command
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Test action with build command
|
||||
uses: ./
|
||||
@@ -270,14 +184,9 @@ jobs:
|
||||
install-node: 'true'
|
||||
server-path: './test-server'
|
||||
build-command: 'echo "Build complete" > build.log'
|
||||
server-repository: ${{ env.TEST_SERVER_REPOSITORY }}
|
||||
server-ref: ${{ env.TEST_SERVER_REF }}
|
||||
github-server-url: ${{ env.TEST_GIT_SERVER_URL }}
|
||||
checkout-token: ${{ secrets.TEST_SERVER_TOKEN }}
|
||||
|
||||
- name: Verify build
|
||||
run: |
|
||||
cd ./test-server
|
||||
test -f build.log
|
||||
grep -q '^Build complete$' build.log
|
||||
echo "✓ Custom build command completed successfully"
|
||||
test -f ./test-server/build.log || exit 1
|
||||
grep -q "Build complete" ./test-server/build.log || exit 1
|
||||
echo "✓ Build command executed successfully"
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
# Quick Start Guide
|
||||
|
||||
Get started with the Server Install Action in minutes!
|
||||
|
||||
## 1. Choose Your Components
|
||||
|
||||
The action installs the Nodarx server and can set up Node.js, PHP, and/or nginx based on your needs.
|
||||
|
||||
## 2. Basic Examples
|
||||
|
||||
### Node.js Only (Unit Tests)
|
||||
|
||||
```yaml
|
||||
name: Node.js Tests
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
```
|
||||
|
||||
### PHP Only (Unit Tests)
|
||||
|
||||
```yaml
|
||||
name: PHP Tests
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-php: 'true'
|
||||
```
|
||||
|
||||
### All Components (Integration Tests)
|
||||
|
||||
```yaml
|
||||
name: Integration Tests
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
install-php: 'true'
|
||||
install-nginx: 'true'
|
||||
```
|
||||
|
||||
## 3. Customize Components
|
||||
|
||||
### Node.js with Specific Version
|
||||
|
||||
```yaml
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
node-version: '20'
|
||||
package-manager: 'pnpm' # or 'npm', 'yarn'
|
||||
```
|
||||
|
||||
### PHP with Custom Extensions
|
||||
|
||||
```yaml
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-php: 'true'
|
||||
php-version: '8.2'
|
||||
php-extensions: 'mbstring, xml, pdo, pdo_mysql'
|
||||
```
|
||||
|
||||
### nginx with Custom Config
|
||||
|
||||
```yaml
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-nginx: 'true'
|
||||
nginx-config: './config/nginx.conf'
|
||||
```
|
||||
|
||||
## 4. Component Combinations
|
||||
|
||||
You can enable any combination of components:
|
||||
|
||||
```yaml
|
||||
# Node.js + nginx (for frontend tests)
|
||||
install-node: 'true'
|
||||
install-nginx: 'true'
|
||||
|
||||
# PHP + nginx (for backend tests)
|
||||
install-php: 'true'
|
||||
install-nginx: 'true'
|
||||
|
||||
# All three (full integration)
|
||||
install-node: 'true'
|
||||
install-php: 'true'
|
||||
install-nginx: 'true'
|
||||
```
|
||||
|
||||
## 5. Common Options
|
||||
|
||||
```yaml
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
# Components (at least one required)
|
||||
install-node: 'true' # Install Node.js
|
||||
install-php: 'true' # Install PHP
|
||||
install-nginx: 'true' # Install nginx
|
||||
|
||||
# Server configuration
|
||||
server-path: './server' # Where to clone (default)
|
||||
|
||||
# Node.js options (if install-node: true)
|
||||
node-version: '20'
|
||||
package-manager: 'npm'
|
||||
|
||||
# PHP options (if install-php: true)
|
||||
php-version: '8.2'
|
||||
php-extensions: 'mbstring, xml, ctype'
|
||||
|
||||
# nginx options (if install-nginx: true)
|
||||
nginx-config: './nginx.conf'
|
||||
|
||||
# General options
|
||||
install-dependencies: 'true'
|
||||
build-command: 'npm run build'
|
||||
env-file: '.env.production'
|
||||
post-install-script: './scripts/setup.sh'
|
||||
```
|
||||
|
||||
- Check the [README.md](README.md) for detailed documentation
|
||||
- See [test workflow](.github/workflows/test.yml) for more usage examples
|
||||
- Read [CONTRIBUTING.md](CONTRIBUTING.md) to contribute
|
||||
- Report issues or request features in [Issues](../../issues)
|
||||
|
||||
## Need Help?
|
||||
|
||||
- 📖 [Full Documentation](README.md)
|
||||
- 💬 [Discussions](../../discussions)
|
||||
- 🐛 [Report a Bug](../../issues/new?template=bug_report.md)
|
||||
- ✨ [Request a Feature](../../issues/new?template=feature_request.md)
|
||||
@@ -1,12 +1,14 @@
|
||||
# Server Install Action
|
||||
|
||||
A 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.
|
||||
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
|
||||
@@ -24,10 +26,11 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Server with Node.js
|
||||
uses: Nodarx/action-server-install@v1
|
||||
uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
node-version: '24'
|
||||
node-version: '20'
|
||||
package-manager: 'npm'
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
@@ -46,10 +49,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Server with PHP
|
||||
uses: Nodarx/action-server-install@v1
|
||||
uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-php: 'true'
|
||||
php-version: '8.5'
|
||||
php-version: '8.2'
|
||||
|
||||
- name: Run tests
|
||||
run: |
|
||||
@@ -68,13 +71,13 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Server with All Components
|
||||
uses: Nodarx/action-server-install@v1
|
||||
uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
install-php: 'true'
|
||||
install-nginx: 'true'
|
||||
node-version: '24'
|
||||
php-version: '8.5'
|
||||
node-version: '20'
|
||||
php-version: '8.2'
|
||||
|
||||
- name: Run integration tests
|
||||
run: |
|
||||
@@ -82,62 +85,11 @@ jobs:
|
||||
npm run test:integration
|
||||
```
|
||||
|
||||
### With Database Configuration
|
||||
|
||||
Point the checked-out server at a database (e.g. a `mongo` service container) and write the value into `config/system.php` before dependencies or base modules are installed:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:7
|
||||
ports:
|
||||
- 27017:27017
|
||||
|
||||
steps:
|
||||
- name: Install server with database configuration
|
||||
uses: Nodarx/action-server-install@v1
|
||||
with:
|
||||
install-php: 'true'
|
||||
database-uri: 'mongodb://127.0.0.1:27017/?tls=false'
|
||||
database-name: 'ktrix_ci'
|
||||
app-environment: 'test'
|
||||
```
|
||||
|
||||
Any override left blank keeps the value already committed in `config/system.php`.
|
||||
|
||||
### With Base Modules (Password Authentication)
|
||||
|
||||
`install-base-modules` clones the password authentication provider module (from `base-modules-repository`, via [action-module-install](https://git.ktrix.dev/Nodarx/action-module-install)), then installs and enables it with `bin/console`. This requires PHP and a reachable, configured database:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:7
|
||||
ports:
|
||||
- 27017:27017
|
||||
|
||||
steps:
|
||||
- name: Install server with base modules
|
||||
uses: Nodarx/action-server-install@v1
|
||||
with:
|
||||
install-php: 'true'
|
||||
database-uri: 'mongodb://127.0.0.1:27017/?tls=false'
|
||||
database-name: 'ktrix_ci'
|
||||
install-base-modules: 'true'
|
||||
|
||||
- name: Provision a tenant and user for testing
|
||||
run: |
|
||||
cd server
|
||||
php bin/console tenant:create ci.test --identifier ci
|
||||
php bin/console user:create ci tester@ci.test
|
||||
php bin/console user:password ci tester@ci.test 'Sup3r-Secret!'
|
||||
```
|
||||
|
||||
### With Custom nginx Configuration
|
||||
|
||||
```yaml
|
||||
- name: Install Server with nginx
|
||||
uses: Nodarx/action-server-install@v1
|
||||
uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-nginx: 'true'
|
||||
nginx-config: './config/nginx.conf'
|
||||
@@ -153,19 +105,26 @@ 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@v1
|
||||
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'
|
||||
```
|
||||
|
||||
@@ -188,20 +147,21 @@ jobs:
|
||||
| `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 | `24` |
|
||||
|
||||
| `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.5` |
|
||||
| `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
|
||||
@@ -210,54 +170,6 @@ jobs:
|
||||
|-------|-------------|----------|---------|
|
||||
| `nginx-config` | Path to nginx configuration file | No | `''` |
|
||||
|
||||
### Server Settings Configuration
|
||||
|
||||
Overrides are written into the checked-out `config/system.php`. Requires `install-php: 'true'`; any input left blank keeps the repository's committed default.
|
||||
|
||||
| Input | Description | Required | Default |
|
||||
|-------|-------------|----------|---------|
|
||||
| `database-uri` | MongoDB connection URI | No | `''` |
|
||||
| `database-name` | MongoDB database name | No | `''` |
|
||||
| `app-environment` | Application environment, e.g. `test` | No | `''` |
|
||||
| `security-salt` | Security salt | No | `''` |
|
||||
|
||||
### Base Modules
|
||||
|
||||
Clones the configured module repository directly, then installs and enables the
|
||||
module via `bin/console`. This avoids a nested remote-action dependency, so the
|
||||
action works on GitHub-compatible hosts without resolving
|
||||
`Nodarx/action-module-install` through GitHub. Requires `install-php` and a
|
||||
reachable, configured database.
|
||||
|
||||
| Input | Description | Required | Default |
|
||||
|-------|-------------|----------|---------|
|
||||
| `install-base-modules` | Clone, install, and enable the base module set (currently: `authentication_provider_password`) | No | `false` |
|
||||
| `base-modules-repository` | Repository URL for the password authentication provider module | No | `https://git.ktrix.dev/Nodarx/authentication_provider_password` |
|
||||
| `base-modules-branch` | Branch, tag, or commit to check out for the password authentication provider module | No | `main` |
|
||||
|
||||
## Testing Against Another Source
|
||||
|
||||
The action's test workflow keeps its server fixture source in repository
|
||||
variables. The defaults target `Nodarx/server` on `https://git.ktrix.dev`.
|
||||
To test another source without editing the workflow, set:
|
||||
|
||||
| Repository variable | Purpose | Default |
|
||||
|---------------------|---------|---------|
|
||||
| `TEST_SERVER_REPOSITORY` | Repository in `owner/name` form | `Nodarx/server` |
|
||||
| `TEST_SERVER_REF` | Branch, tag, or commit | `main` |
|
||||
| `TEST_GIT_SERVER_URL` | Base URL of the GitHub-compatible server | `https://git.ktrix.dev` |
|
||||
| `TEST_DATABASE_URI` | MongoDB service URI used by database tests | `mongodb://mongo:27017/?tls=false` |
|
||||
|
||||
For a private source, also add a repository secret named
|
||||
`TEST_SERVER_TOKEN`. Public repositories do not require the secret.
|
||||
|
||||
Gitea Actions runs the job and service containers separately. Workflows that
|
||||
declare a MongoDB service named `mongo` must therefore pass
|
||||
`database-uri: mongodb://mongo:27017/?tls=false`; `127.0.0.1` points to the job
|
||||
container, not the MongoDB service. On runner setups where services are
|
||||
published directly onto the host, override `TEST_DATABASE_URI` with the
|
||||
appropriate host address.
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output | Description |
|
||||
@@ -267,21 +179,47 @@ appropriate host address.
|
||||
| `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) |
|
||||
| `base-modules-installed` | Whether the base module set 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
|
||||
```yaml
|
||||
# JS unit tests - Node.js only
|
||||
- uses: Nodarx/action-server-install@v1
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
```
|
||||
|
||||
2. **Pin to specific versions**: Use commit SHA or version tag
|
||||
```yaml
|
||||
uses: Nodarx/action-server-install@v1.0.0
|
||||
uses: Nodarx/action-server-install@v2.0.0
|
||||
```
|
||||
|
||||
3. **Cache dependencies**: Combine with caching for faster builds
|
||||
@@ -291,12 +229,24 @@ appropriate host address.
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('server/package-lock.json') }}
|
||||
|
||||
- uses: Nodarx/action-server-install@v1
|
||||
- uses: Nodarx/action-server-install@v2
|
||||
with:
|
||||
install-node: 'true'
|
||||
```
|
||||
|
||||
4. **Test different component combinations**: Matrix testing
|
||||
4. **Secure secrets**: Use GitHub Secrets for sensitive variables
|
||||
```yaml
|
||||
- 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
|
||||
```yaml
|
||||
strategy:
|
||||
matrix:
|
||||
@@ -312,6 +262,49 @@ appropriate host address.
|
||||
install-php: 'true'
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Local Testing
|
||||
|
||||
To test this action locally, you can use [act](https://github.com/nektos/act):
|
||||
|
||||
```bash
|
||||
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](https://semver.org/). For the versions available, see the [tags on this repository](../../tags).
|
||||
|
||||
### Major Version Tags
|
||||
|
||||
Major version tags (v1, v2, etc.) are maintained to point to the latest minor/patch release within that major version:
|
||||
|
||||
```yaml
|
||||
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](LICENSE) file for details.
|
||||
|
||||
## Support
|
||||
|
||||
If you encounter any issues or have questions:
|
||||
- Open an [issue](../../issues)
|
||||
- Check [existing discussions](../../discussions)
|
||||
|
||||
## Acknowledgments
|
||||
|
||||
- Inspired by GitHub's official actions
|
||||
- Built with the GitHub Actions community
|
||||
|
||||
+85
-145
@@ -31,6 +31,10 @@ inputs:
|
||||
description: 'Node.js version to use (if install-node is true)'
|
||||
required: false
|
||||
default: '24'
|
||||
package-manager:
|
||||
description: 'Package manager for Node.js (npm, yarn, pnpm)'
|
||||
required: false
|
||||
default: 'npm'
|
||||
php-version:
|
||||
description: 'PHP version to use (if install-php is true)'
|
||||
required: false
|
||||
@@ -47,54 +51,14 @@ inputs:
|
||||
description: 'Custom build command to run after install'
|
||||
required: false
|
||||
default: ''
|
||||
env-file:
|
||||
description: 'Path to environment file to copy (.env)'
|
||||
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:
|
||||
@@ -112,9 +76,6 @@ outputs:
|
||||
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'
|
||||
@@ -123,52 +84,52 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::Validating inputs"
|
||||
|
||||
bash "${{ github.action_path }}/scripts/validate-inputs.sh" \
|
||||
"${{ inputs.install-node }}" \
|
||||
"${{ inputs.install-php }}" \
|
||||
"${{ inputs.install-nginx }}" \
|
||||
"${{ inputs.install-base-modules }}"
|
||||
|
||||
|
||||
# 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-node }}" == "true" ] && echo " ✓ Node.js ${{ inputs.node-version }} (${{ inputs.package-manager }})"
|
||||
[ "${{ 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@v6.0.2
|
||||
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: Clone server repository
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::Cloning Nodarx server repository"
|
||||
|
||||
if [ -d "${{ inputs.server-path }}" ]; then
|
||||
echo "Directory exists, pulling latest changes..."
|
||||
cd "${{ inputs.server-path }}"
|
||||
git pull --recurse-submodules || echo "::warning::Pull failed, continuing with existing code"
|
||||
else
|
||||
echo "Cloning repository..."
|
||||
git clone --recurse-submodules --depth 1 https://git.ktrix.dev/Nodarx/server "${{ inputs.server-path }}"
|
||||
fi
|
||||
|
||||
echo "Repository cloned/updated successfully"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Checkout server repository (with token)
|
||||
if: inputs.checkout-token != ''
|
||||
uses: actions/checkout@v6.0.2
|
||||
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
|
||||
- name: Setup Node.js
|
||||
if: inputs.install-node == 'true'
|
||||
uses: actions/setup-node@v6.2.0
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ inputs.node-version }}
|
||||
|
||||
- name: Setup pnpm
|
||||
if: inputs.install-node == 'true' && inputs.package-manager == 'pnpm'
|
||||
uses: pnpm/action-setup@v2
|
||||
with:
|
||||
version: 8
|
||||
|
||||
- name: Setup PHP
|
||||
if: inputs.install-php == 'true'
|
||||
uses: shivammathur/setup-php@v2
|
||||
@@ -178,25 +139,6 @@ runs:
|
||||
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
|
||||
@@ -204,7 +146,7 @@ runs:
|
||||
echo "::group::Installing nginx"
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y nginx
|
||||
echo "✓ nginx installed successfully"
|
||||
echo "nginx installed successfully"
|
||||
nginx -v
|
||||
echo "::endgroup::"
|
||||
|
||||
@@ -217,12 +159,12 @@ runs:
|
||||
if [ -f "${{ inputs.nginx-config }}" ]; then
|
||||
sudo cp "${{ inputs.nginx-config }}" /etc/nginx/sites-available/default
|
||||
sudo nginx -t
|
||||
echo "✓ nginx configured successfully"
|
||||
echo "nginx configured successfully"
|
||||
else
|
||||
echo "::warning::nginx config file not found: ${{ inputs.nginx-config }}"
|
||||
fi
|
||||
|
||||
echo "::endgroup::"
|
||||
echo "::endgroup:"
|
||||
|
||||
- name: Start nginx
|
||||
if: inputs.install-nginx == 'true'
|
||||
@@ -237,17 +179,33 @@ runs:
|
||||
if pgrep nginx >/dev/null; then
|
||||
echo "✓ nginx is running"
|
||||
fi
|
||||
echo "✓ nginx started successfully"
|
||||
echo "::endgroup::"
|
||||
echo "nginx started successfully"
|
||||
echo "::endgroup:"
|
||||
|
||||
- name: Install Node dependencies
|
||||
- name: Install Node.js dependencies
|
||||
if: inputs.install-node == 'true' && inputs.install-dependencies == 'true'
|
||||
shell: bash
|
||||
run: |
|
||||
echo "::group::Installing Node dependencies"
|
||||
echo "::group::Installing Node.js dependencies"
|
||||
cd "${{ inputs.server-path }}"
|
||||
npm ci || npm install
|
||||
echo "✓ Node dependencies installed successfully"
|
||||
|
||||
case "${{ inputs.package-manager }}" in
|
||||
npm)
|
||||
npm ci || npm install
|
||||
;;
|
||||
yarn)
|
||||
yarn install --frozen-lockfile || yarn install
|
||||
;;
|
||||
pnpm)
|
||||
pnpm install --frozen-lockfile || pnpm install
|
||||
;;
|
||||
*)
|
||||
echo "::error::Unsupported package manager: ${{ inputs.package-manager }}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Node.js dependencies installed successfully"
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Install PHP dependencies
|
||||
@@ -256,46 +214,29 @@ runs:
|
||||
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
|
||||
|
||||
if [ -f "composer.json" ]; then
|
||||
composer install --optimize-autoloader
|
||||
echo "PHP dependencies installed successfully"
|
||||
else
|
||||
echo "::warning::composer.json not found, skipping PHP dependency installation"
|
||||
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'
|
||||
- name: Copy environment file
|
||||
if: inputs.env-file != ''
|
||||
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 "::group::Setting up environment file"
|
||||
|
||||
if [ -f "${{ inputs.env-file }}" ]; then
|
||||
cp "${{ inputs.env-file }}" "${{ inputs.server-path }}/.env"
|
||||
echo "Environment file copied successfully"
|
||||
else
|
||||
echo "::warning::Environment file not found: ${{ inputs.env-file }}"
|
||||
fi
|
||||
|
||||
echo "::endgroup::"
|
||||
|
||||
- name: Run build command
|
||||
@@ -326,4 +267,3 @@ runs:
|
||||
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
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Applies environment-provided overrides to a Ktrix server's config/system.php.
|
||||
*
|
||||
* Used by action-server-install to point a freshly checked-out server at the
|
||||
* database and settings provided by the calling CI workflow, without hand
|
||||
* editing the repository's committed config file.
|
||||
*
|
||||
* Usage: php configure-server.php <path-to-config/system.php>
|
||||
*
|
||||
* All overrides are read from environment variables and are optional; an
|
||||
* unset or empty variable leaves the corresponding config value untouched:
|
||||
* DATABASE_URI -> $config['database']['uri']
|
||||
* DATABASE_NAME -> $config['database']['database']
|
||||
* APP_ENVIRONMENT -> $config['environment']
|
||||
* SECURITY_SALT -> $config['security.salt']
|
||||
*/
|
||||
|
||||
$path = $argv[1] ?? null;
|
||||
|
||||
if (!$path || !is_file($path)) {
|
||||
fwrite(STDERR, "Configuration file not found: {$path}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$config = include $path;
|
||||
|
||||
if (!is_array($config)) {
|
||||
fwrite(STDERR, "Configuration file did not return an array: {$path}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Nested overrides: env var => [top-level key, nested key]
|
||||
$nestedOverrides = [
|
||||
'DATABASE_URI' => ['database', 'uri'],
|
||||
'DATABASE_NAME' => ['database', 'database'],
|
||||
];
|
||||
|
||||
foreach ($nestedOverrides as $env => [$group, $key]) {
|
||||
$value = getenv($env);
|
||||
if ($value === false || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$config[$group][$key] = $value;
|
||||
echo " - {$group}.{$key} overridden\n";
|
||||
}
|
||||
|
||||
// Flat overrides: env var => config key
|
||||
$flatOverrides = [
|
||||
'APP_ENVIRONMENT' => 'environment',
|
||||
'SECURITY_SALT' => 'security.salt',
|
||||
];
|
||||
|
||||
foreach ($flatOverrides as $env => $key) {
|
||||
$value = getenv($env);
|
||||
if ($value === false || $value === '') {
|
||||
continue;
|
||||
}
|
||||
$config[$key] = $value;
|
||||
echo " - {$key} overridden\n";
|
||||
}
|
||||
|
||||
$export = var_export($config, true);
|
||||
file_put_contents($path, "<?php\n\nreturn {$export};\n");
|
||||
|
||||
echo "Configuration written to {$path}\n";
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
install_node="${1:-false}"
|
||||
install_php="${2:-false}"
|
||||
install_nginx="${3:-false}"
|
||||
install_base_modules="${4:-false}"
|
||||
|
||||
if [ "$install_node" != "true" ] &&
|
||||
[ "$install_php" != "true" ] &&
|
||||
[ "$install_nginx" != "true" ]; then
|
||||
echo "::error::At least one component must be enabled (install-node, install-php, or install-nginx)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$install_base_modules" = "true" ] && [ "$install_php" != "true" ]; then
|
||||
echo "::error::install-base-modules requires install-php to be 'true'"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user