Compare commits
1 Commits
main
..
b843124cd6
| Author | SHA1 | Date | |
|---|---|---|---|
| b843124cd6 |
+57
-151
@@ -5,34 +5,19 @@ 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
|
||||
- uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Test action with Node.js (npm)
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-node: 'true'
|
||||
node-version: '24'
|
||||
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 +25,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
|
||||
- uses: actions/checkout@v6.0.2
|
||||
|
||||
- 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 +52,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
|
||||
- uses: actions/checkout@v6.0.2
|
||||
|
||||
- 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: |
|
||||
@@ -193,12 +85,9 @@ jobs:
|
||||
name: Test All Components
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Test action with all components
|
||||
id: install
|
||||
uses: ./
|
||||
with:
|
||||
install-node: 'true'
|
||||
@@ -207,10 +96,6 @@ jobs:
|
||||
node-version: '24'
|
||||
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: |
|
||||
@@ -223,46 +108,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
|
||||
- uses: actions/checkout@v6.0.2
|
||||
|
||||
- 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@v6.0.2
|
||||
|
||||
- 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
|
||||
- uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Test action with build command
|
||||
uses: ./
|
||||
@@ -270,14 +182,8 @@ 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"
|
||||
npm run dev
|
||||
|
||||
@@ -82,57 +82,6 @@ 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
|
||||
@@ -210,54 +159,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,7 +168,6 @@ 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) |
|
||||
|
||||
## Best Practices
|
||||
|
||||
|
||||
+25
-136
@@ -51,50 +51,6 @@ inputs:
|
||||
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 +68,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,13 +76,15 @@ 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 }}"
|
||||
@@ -138,30 +93,22 @@ runs:
|
||||
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: 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: 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: Setup Node
|
||||
if: inputs.install-node == 'true'
|
||||
@@ -178,25 +125,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
|
||||
@@ -260,44 +188,6 @@ runs:
|
||||
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
|
||||
@@ -326,4 +216,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