Compare commits
1 Commits
main
...
8c5570bddd
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c5570bddd |
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6.0.2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
43
.github/workflows/test.yml
vendored
43
.github/workflows/test.yml
vendored
@@ -10,13 +10,14 @@ jobs:
|
|||||||
name: Test Node
|
name: Test Node
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6.0.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test action with Node.js (npm)
|
- name: Test action with Node.js (npm)
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
install-node: 'true'
|
install-node: 'true'
|
||||||
node-version: '24'
|
node-version: '24'
|
||||||
|
package-manager: 'npm'
|
||||||
server-path: './test-server'
|
server-path: './test-server'
|
||||||
|
|
||||||
- name: Verify installation
|
- name: Verify installation
|
||||||
@@ -36,7 +37,7 @@ jobs:
|
|||||||
name: Test PHP
|
name: Test PHP
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6.0.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test action with PHP
|
- name: Test action with PHP
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -63,7 +64,7 @@ jobs:
|
|||||||
name: Test nginx
|
name: Test nginx
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6.0.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test action with nginx
|
- name: Test action with nginx
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -85,7 +86,7 @@ jobs:
|
|||||||
name: Test All Components
|
name: Test All Components
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6.0.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test action with all components
|
- name: Test action with all components
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -95,6 +96,7 @@ jobs:
|
|||||||
install-nginx: 'true'
|
install-nginx: 'true'
|
||||||
node-version: '24'
|
node-version: '24'
|
||||||
php-version: '8.5'
|
php-version: '8.5'
|
||||||
|
package-manager: 'npm'
|
||||||
server-path: './test-server'
|
server-path: './test-server'
|
||||||
|
|
||||||
- name: Verify installation
|
- name: Verify installation
|
||||||
@@ -123,7 +125,7 @@ jobs:
|
|||||||
name: Test Custom Server Path
|
name: Test Custom Server Path
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6.0.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test action with custom path
|
- name: Test action with custom path
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -146,11 +148,35 @@ jobs:
|
|||||||
echo "⚠ No test script configured, skipping"
|
echo "⚠ No test script configured, skipping"
|
||||||
fi
|
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:
|
test-build-command:
|
||||||
name: Test Build Command
|
name: Test Build Command
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6.0.2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Test action with build command
|
- name: Test action with build command
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -161,5 +187,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Verify build
|
- name: Verify build
|
||||||
run: |
|
run: |
|
||||||
cd ./test-server
|
test -f ./test-server/build.log || exit 1
|
||||||
npm run dev
|
grep -q "Build complete" ./test-server/build.log || exit 1
|
||||||
|
echo "✓ Build command executed successfully"
|
||||||
|
|||||||
149
QUICK_START.md
Normal file
149
QUICK_START.md
Normal file
@@ -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)
|
||||||
127
README.md
127
README.md
@@ -1,12 +1,14 @@
|
|||||||
# Server Install Action
|
# 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
|
## Features
|
||||||
|
|
||||||
- ✅ Clone Nodarx server repository with submodule support
|
- ✅ Clone Nodarx server repository with submodule support
|
||||||
- ✅ Flexible component installation (Node.js, PHP, nginx)
|
- ✅ Flexible component installation (Node.js, PHP, nginx)
|
||||||
|
- ✅ Support for multiple Node.js package managers (npm, yarn, pnpm)
|
||||||
- ✅ Automatic dependency installation (npm, composer)
|
- ✅ Automatic dependency installation (npm, composer)
|
||||||
|
- ✅ Environment file configuration
|
||||||
- ✅ Custom build commands
|
- ✅ Custom build commands
|
||||||
- ✅ Post-installation scripts
|
- ✅ Post-installation scripts
|
||||||
- ✅ Comprehensive error handling and logging
|
- ✅ Comprehensive error handling and logging
|
||||||
@@ -24,10 +26,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Server with Node.js
|
- name: Install Server with Node.js
|
||||||
uses: Nodarx/action-server-install@v1
|
uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
install-node: 'true'
|
install-node: 'true'
|
||||||
node-version: '24'
|
node-version: '20'
|
||||||
|
package-manager: 'npm'
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
@@ -46,10 +49,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Server with PHP
|
- name: Install Server with PHP
|
||||||
uses: Nodarx/action-server-install@v1
|
uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
install-php: 'true'
|
install-php: 'true'
|
||||||
php-version: '8.5'
|
php-version: '8.2'
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
@@ -68,13 +71,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Server with All Components
|
- name: Install Server with All Components
|
||||||
uses: Nodarx/action-server-install@v1
|
uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
install-node: 'true'
|
install-node: 'true'
|
||||||
install-php: 'true'
|
install-php: 'true'
|
||||||
install-nginx: 'true'
|
install-nginx: 'true'
|
||||||
node-version: '24'
|
node-version: '20'
|
||||||
php-version: '8.5'
|
php-version: '8.2'
|
||||||
|
|
||||||
- name: Run integration tests
|
- name: Run integration tests
|
||||||
run: |
|
run: |
|
||||||
@@ -86,7 +89,7 @@ jobs:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Install Server with nginx
|
- name: Install Server with nginx
|
||||||
uses: Nodarx/action-server-install@v1
|
uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
install-nginx: 'true'
|
install-nginx: 'true'
|
||||||
nginx-config: './config/nginx.conf'
|
nginx-config: './config/nginx.conf'
|
||||||
@@ -102,19 +105,26 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
- name: Install Server
|
||||||
uses: Nodarx/action-server-install@v1
|
uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
server-path: './server'
|
server-path: './server'
|
||||||
install-node: 'true'
|
install-node: 'true'
|
||||||
install-php: 'true'
|
install-php: 'true'
|
||||||
install-nginx: 'true'
|
install-nginx: 'true'
|
||||||
node-version: '20'
|
node-version: '20'
|
||||||
|
package-manager: 'pnpm'
|
||||||
php-version: '8.2'
|
php-version: '8.2'
|
||||||
php-extensions: 'mbstring, xml, ctype, json, curl, zip, pdo, pdo_mysql'
|
php-extensions: 'mbstring, xml, ctype, json, curl, zip, pdo, pdo_mysql'
|
||||||
nginx-config: './config/nginx.conf'
|
nginx-config: './config/nginx.conf'
|
||||||
install-dependencies: 'true'
|
install-dependencies: 'true'
|
||||||
build-command: 'npm run build'
|
build-command: 'npm run build'
|
||||||
|
env-file: '.env.production'
|
||||||
post-install-script: './scripts/post-install.sh'
|
post-install-script: './scripts/post-install.sh'
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -137,20 +147,21 @@ jobs:
|
|||||||
| `server-path` | Path where the server will be cloned/installed | No | `./server` |
|
| `server-path` | Path where the server will be cloned/installed | No | `./server` |
|
||||||
| `install-dependencies` | Whether to install dependencies (npm/composer) | No | `true` |
|
| `install-dependencies` | Whether to install dependencies (npm/composer) | No | `true` |
|
||||||
| `build-command` | Custom build command to run after install | No | `''` |
|
| `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 | `''` |
|
| `post-install-script` | Custom script to run after installation | No | `''` |
|
||||||
|
|
||||||
### Node.js Configuration
|
### Node.js Configuration
|
||||||
|
|
||||||
| Input | Description | Required | Default |
|
| 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
|
### PHP Configuration
|
||||||
|
|
||||||
| Input | Description | Required | Default |
|
| 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` |
|
| `php-extensions` | Comma-separated list of PHP extensions to install | No | `mbstring, xml, ctype, json, curl, zip` |
|
||||||
|
|
||||||
### nginx Configuration
|
### nginx Configuration
|
||||||
@@ -169,19 +180,46 @@ jobs:
|
|||||||
| `php-installed` | Whether PHP was installed (true/false) |
|
| `php-installed` | Whether PHP was installed (true/false) |
|
||||||
| `nginx-installed` | Whether nginx 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
|
## Best Practices
|
||||||
|
|
||||||
1. **Enable only needed components**: For faster test runs
|
1. **Enable only needed components**: For faster test runs
|
||||||
```yaml
|
```yaml
|
||||||
# JS unit tests - Node.js only
|
# JS unit tests - Node.js only
|
||||||
- uses: Nodarx/action-server-install@v1
|
- uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
install-node: 'true'
|
install-node: 'true'
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Pin to specific versions**: Use commit SHA or version tag
|
2. **Pin to specific versions**: Use commit SHA or version tag
|
||||||
```yaml
|
```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
|
3. **Cache dependencies**: Combine with caching for faster builds
|
||||||
@@ -191,12 +229,24 @@ jobs:
|
|||||||
path: ~/.npm
|
path: ~/.npm
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('server/package-lock.json') }}
|
key: ${{ runner.os }}-node-${{ hashFiles('server/package-lock.json') }}
|
||||||
|
|
||||||
- uses: Nodarx/action-server-install@v1
|
- uses: Nodarx/action-server-install@v2
|
||||||
with:
|
with:
|
||||||
install-node: 'true'
|
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
|
```yaml
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
@@ -212,6 +262,49 @@ jobs:
|
|||||||
install-php: 'true'
|
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
|
## License
|
||||||
|
|
||||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
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
|
||||||
|
|||||||
127
action.yml
127
action.yml
@@ -31,6 +31,10 @@ inputs:
|
|||||||
description: 'Node.js version to use (if install-node is true)'
|
description: 'Node.js version to use (if install-node is true)'
|
||||||
required: false
|
required: false
|
||||||
default: '24'
|
default: '24'
|
||||||
|
package-manager:
|
||||||
|
description: 'Package manager for Node.js (npm, yarn, pnpm)'
|
||||||
|
required: false
|
||||||
|
default: 'npm'
|
||||||
php-version:
|
php-version:
|
||||||
description: 'PHP version to use (if install-php is true)'
|
description: 'PHP version to use (if install-php is true)'
|
||||||
required: false
|
required: false
|
||||||
@@ -47,24 +51,12 @@ inputs:
|
|||||||
description: 'Custom build command to run after install'
|
description: 'Custom build command to run after install'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
post-install-script:
|
env-file:
|
||||||
description: 'Custom script to run after installation'
|
description: 'Path to environment file to copy (.env)'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
server-repository:
|
post-install-script:
|
||||||
description: 'Repository to checkout for the server source'
|
description: 'Custom script to run after installation'
|
||||||
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
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
|
||||||
@@ -103,41 +95,41 @@ runs:
|
|||||||
|
|
||||||
echo "Server path: ${{ inputs.server-path }}"
|
echo "Server path: ${{ inputs.server-path }}"
|
||||||
echo "Components to install:"
|
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-php }}" == "true" ] && echo " ✓ PHP ${{ inputs.php-version }}"
|
||||||
[ "${{ inputs.install-nginx }}" == "true" ] && echo " ✓ nginx"
|
[ "${{ inputs.install-nginx }}" == "true" ] && echo " ✓ nginx"
|
||||||
echo "Install dependencies: ${{ inputs.install-dependencies }}"
|
echo "Install dependencies: ${{ inputs.install-dependencies }}"
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Checkout server repository (public/no token)
|
- name: Clone server repository
|
||||||
if: inputs.checkout-token == ''
|
shell: bash
|
||||||
uses: actions/checkout@v4
|
run: |
|
||||||
with:
|
echo "::group::Cloning Nodarx server repository"
|
||||||
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 [ -d "${{ inputs.server-path }}" ]; then
|
||||||
if: inputs.checkout-token != ''
|
echo "Directory exists, pulling latest changes..."
|
||||||
uses: actions/checkout@v4
|
cd "${{ inputs.server-path }}"
|
||||||
with:
|
git pull --recurse-submodules || echo "::warning::Pull failed, continuing with existing code"
|
||||||
repository: ${{ inputs.server-repository }}
|
else
|
||||||
ref: ${{ inputs.server-ref }}
|
echo "Cloning repository..."
|
||||||
path: ${{ inputs.server-path }}
|
git clone --recurse-submodules --depth 1 https://git.ktrix.dev/Nodarx/server "${{ inputs.server-path }}"
|
||||||
fetch-depth: 1
|
fi
|
||||||
submodules: recursive
|
|
||||||
github-server-url: ${{ inputs.github-server-url }}
|
|
||||||
token: ${{ inputs.checkout-token }}
|
|
||||||
|
|
||||||
- name: Setup Node
|
echo "Repository cloned/updated successfully"
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
if: inputs.install-node == 'true'
|
if: inputs.install-node == 'true'
|
||||||
uses: actions/setup-node@v6.2.0
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ inputs.node-version }}
|
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
|
- name: Setup PHP
|
||||||
if: inputs.install-php == 'true'
|
if: inputs.install-php == 'true'
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
@@ -154,7 +146,7 @@ runs:
|
|||||||
echo "::group::Installing nginx"
|
echo "::group::Installing nginx"
|
||||||
sudo apt-get update -qq
|
sudo apt-get update -qq
|
||||||
sudo apt-get install -y nginx
|
sudo apt-get install -y nginx
|
||||||
echo "✓ nginx installed successfully"
|
echo "nginx installed successfully"
|
||||||
nginx -v
|
nginx -v
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
@@ -167,12 +159,12 @@ runs:
|
|||||||
if [ -f "${{ inputs.nginx-config }}" ]; then
|
if [ -f "${{ inputs.nginx-config }}" ]; then
|
||||||
sudo cp "${{ inputs.nginx-config }}" /etc/nginx/sites-available/default
|
sudo cp "${{ inputs.nginx-config }}" /etc/nginx/sites-available/default
|
||||||
sudo nginx -t
|
sudo nginx -t
|
||||||
echo "✓ nginx configured successfully"
|
echo "nginx configured successfully"
|
||||||
else
|
else
|
||||||
echo "::warning::nginx config file not found: ${{ inputs.nginx-config }}"
|
echo "::warning::nginx config file not found: ${{ inputs.nginx-config }}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::endgroup::"
|
echo "::endgroup:"
|
||||||
|
|
||||||
- name: Start nginx
|
- name: Start nginx
|
||||||
if: inputs.install-nginx == 'true'
|
if: inputs.install-nginx == 'true'
|
||||||
@@ -187,17 +179,33 @@ runs:
|
|||||||
if pgrep nginx >/dev/null; then
|
if pgrep nginx >/dev/null; then
|
||||||
echo "✓ nginx is running"
|
echo "✓ nginx is running"
|
||||||
fi
|
fi
|
||||||
echo "✓ nginx started successfully"
|
echo "nginx started successfully"
|
||||||
echo "::endgroup::"
|
echo "::endgroup:"
|
||||||
|
|
||||||
- name: Install Node dependencies
|
- name: Install Node.js dependencies
|
||||||
if: inputs.install-node == 'true' && inputs.install-dependencies == 'true'
|
if: inputs.install-node == 'true' && inputs.install-dependencies == 'true'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "::group::Installing Node dependencies"
|
echo "::group::Installing Node.js dependencies"
|
||||||
cd "${{ inputs.server-path }}"
|
cd "${{ inputs.server-path }}"
|
||||||
|
|
||||||
|
case "${{ inputs.package-manager }}" in
|
||||||
|
npm)
|
||||||
npm ci || npm install
|
npm ci || npm install
|
||||||
echo "✓ Node dependencies installed successfully"
|
;;
|
||||||
|
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::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Install PHP dependencies
|
- name: Install PHP dependencies
|
||||||
@@ -206,8 +214,29 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
echo "::group::Installing PHP dependencies"
|
echo "::group::Installing PHP dependencies"
|
||||||
cd "${{ inputs.server-path }}"
|
cd "${{ inputs.server-path }}"
|
||||||
|
|
||||||
|
if [ -f "composer.json" ]; then
|
||||||
composer install --optimize-autoloader
|
composer install --optimize-autoloader
|
||||||
echo "✓ PHP dependencies installed successfully"
|
echo "PHP dependencies installed successfully"
|
||||||
|
else
|
||||||
|
echo "::warning::composer.json not found, skipping PHP dependency installation"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Copy environment file
|
||||||
|
if: inputs.env-file != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
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::"
|
echo "::endgroup::"
|
||||||
|
|
||||||
- name: Run build command
|
- name: Run build command
|
||||||
|
|||||||
Reference in New Issue
Block a user