feat: initial commit
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
29
.editorconfig
Normal file
29
.editorconfig
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
# EditorConfig helps maintain consistent coding styles
|
||||||
|
# https://editorconfig.org
|
||||||
|
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{md,markdown}]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.sh]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.js]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
13
.github/dependabot.yml
vendored
Normal file
13
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
# GitHub Actions
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
|
- "github-actions"
|
||||||
|
commit-message:
|
||||||
|
prefix: "chore"
|
||||||
|
include: "scope"
|
||||||
59
.github/workflows/release.yml
vendored
Normal file
59
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
name: Release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Get version from tag
|
||||||
|
id: version
|
||||||
|
run: |
|
||||||
|
VERSION=${GITHUB_REF#refs/tags/v}
|
||||||
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||||
|
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Extract changelog
|
||||||
|
id: changelog
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
# Extract the changelog section for this version
|
||||||
|
CHANGELOG=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$d')
|
||||||
|
# Use a delimiter to handle multiline
|
||||||
|
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create GitHub Release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.version.outputs.tag }}
|
||||||
|
release_name: Release ${{ steps.version.outputs.tag }}
|
||||||
|
body: ${{ steps.changelog.outputs.changelog }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
||||||
|
- name: Update major version tag
|
||||||
|
run: |
|
||||||
|
VERSION=${{ steps.version.outputs.version }}
|
||||||
|
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
|
||||||
|
|
||||||
|
git config user.name github-actions
|
||||||
|
git config user.email github-actions@github.com
|
||||||
|
|
||||||
|
# Force update the major version tag
|
||||||
|
git tag -fa "v$MAJOR_VERSION" -m "Update v$MAJOR_VERSION to $VERSION"
|
||||||
|
git push origin "v$MAJOR_VERSION" --force
|
||||||
240
.github/workflows/test.yml
vendored
Normal file
240
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
name: Test Action
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-node-npm:
|
||||||
|
name: Test Node.js with npm
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test action with Node.js (npm)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
node-version: '20'
|
||||||
|
package-manager: 'npm'
|
||||||
|
server-path: './test-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./test-server || exit 1
|
||||||
|
test -d ./test-server/node_modules || exit 1
|
||||||
|
chmod +x ./scripts/health-check.sh
|
||||||
|
./scripts/health-check.sh ./test-server true false false
|
||||||
|
echo "✓ Node.js (npm) installation successful"
|
||||||
|
|
||||||
|
- name: Run server tests
|
||||||
|
run: |
|
||||||
|
cd ./test-server
|
||||||
|
npm test
|
||||||
|
|
||||||
|
test-node-yarn:
|
||||||
|
name: Test Node.js with yarn
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Enable Corepack
|
||||||
|
run: corepack enable
|
||||||
|
|
||||||
|
- name: Test action with Node.js (yarn)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
node-version: '20'
|
||||||
|
package-manager: 'yarn'
|
||||||
|
server-path: './test-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./test-server || exit 1
|
||||||
|
test -d ./test-server/node_modules || exit 1
|
||||||
|
chmod +x ./scripts/health-check.sh
|
||||||
|
./scripts/health-check.sh ./test-server true false false
|
||||||
|
echo "✓ Node.js (yarn) installation successful"
|
||||||
|
|
||||||
|
- name: Run server tests
|
||||||
|
run: |
|
||||||
|
cd ./test-server
|
||||||
|
yarn test
|
||||||
|
|
||||||
|
test-node-pnpm:
|
||||||
|
name: Test Node.js with pnpm
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test action with Node.js (pnpm)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
node-version: '20'
|
||||||
|
package-manager: 'pnpm'
|
||||||
|
server-path: './test-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./test-server || exit 1
|
||||||
|
test -d ./test-server/node_modules || exit 1
|
||||||
|
chmod +x ./scripts/health-check.sh
|
||||||
|
./scripts/health-check.sh ./test-server true false false
|
||||||
|
echo "✓ Node.js (pnpm) installation successful"
|
||||||
|
|
||||||
|
- name: Run server tests
|
||||||
|
run: |
|
||||||
|
cd ./test-server
|
||||||
|
pnpm test
|
||||||
|
|
||||||
|
test-php:
|
||||||
|
name: Test PHP
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test action with PHP
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-php: 'true'
|
||||||
|
php-version: '8.2'
|
||||||
|
server-path: './test-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./test-server || exit 1
|
||||||
|
php --version
|
||||||
|
composer --version
|
||||||
|
chmod +x ./scripts/health-check.sh
|
||||||
|
./scripts/health-check.sh ./test-server false true false
|
||||||
|
echo "✓ PHP installation successful"
|
||||||
|
|
||||||
|
- name: Run server tests
|
||||||
|
run: |
|
||||||
|
cd ./test-server
|
||||||
|
./vendor/bin/phpunit
|
||||||
|
|
||||||
|
test-nginx:
|
||||||
|
name: Test nginx
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test action with nginx
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-nginx: 'true'
|
||||||
|
server-path: './test-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./test-server || exit 1
|
||||||
|
nginx -v
|
||||||
|
sudo systemctl status nginx --no-pager
|
||||||
|
chmod +x ./scripts/health-check.sh
|
||||||
|
./scripts/health-check.sh ./test-server false false true
|
||||||
|
echo "✓ nginx installation successful"
|
||||||
|
|
||||||
|
test-all-components:
|
||||||
|
name: Test All Components
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test action with all components
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
install-php: 'true'
|
||||||
|
install-nginx: 'true'
|
||||||
|
node-version: '20'
|
||||||
|
php-version: '8.2'
|
||||||
|
package-manager: 'npm'
|
||||||
|
server-path: './test-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./test-server || exit 1
|
||||||
|
test -d ./test-server/node_modules || exit 1
|
||||||
|
node --version
|
||||||
|
npm --version
|
||||||
|
php --version
|
||||||
|
composer --version
|
||||||
|
nginx -v
|
||||||
|
chmod +x ./scripts/health-check.sh
|
||||||
|
./scripts/health-check.sh ./test-server true true true
|
||||||
|
echo "✓ All components installation successful"
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
run: |
|
||||||
|
cd ./test-server
|
||||||
|
npm run test:integration
|
||||||
|
|
||||||
|
test-custom-paths:
|
||||||
|
name: Test Custom Server Path
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test action with custom path
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
server-path: './my-custom-server'
|
||||||
|
|
||||||
|
- name: Verify installation
|
||||||
|
run: |
|
||||||
|
test -d ./my-custom-server || exit 1
|
||||||
|
test -d ./my-custom-server/node_modules || exit 1
|
||||||
|
echo "✓ Custom path installation successful"
|
||||||
|
|
||||||
|
- name: Run server tests
|
||||||
|
run: |
|
||||||
|
cd ./my-custom-server
|
||||||
|
npm test
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
- name: Test action with build command
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
server-path: './test-server'
|
||||||
|
build-command: 'echo "Build complete" > build.log'
|
||||||
|
|
||||||
|
- name: Verify build
|
||||||
|
run: |
|
||||||
|
test -f ./test-server/build.log || exit 1
|
||||||
|
grep -q "Build complete" ./test-server/build.log || exit 1
|
||||||
|
echo "✓ Build command executed successfully"
|
||||||
52
.gitignore
vendored
Normal file
52
.gitignore
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
vendor/
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
.Python
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.*.local
|
||||||
|
*.env
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
logs/
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
coverage/
|
||||||
|
.nyc_output/
|
||||||
|
*.lcov
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Build outputs
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# OS
|
||||||
|
Thumbs.db
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
*.tmp
|
||||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Nodarx
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
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)
|
||||||
310
README.md
Normal file
310
README.md
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
# Server Install Action
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Node.js Only (Unit Tests)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Node.js Unit Tests
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Server with Node.js
|
||||||
|
uses: Nodarx/action-server-install@v2
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
node-version: '20'
|
||||||
|
package-manager: 'npm'
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
cd server
|
||||||
|
npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
### PHP Only (Unit Tests)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: PHP Unit Tests
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Server with PHP
|
||||||
|
uses: Nodarx/action-server-install@v2
|
||||||
|
with:
|
||||||
|
install-php: 'true'
|
||||||
|
php-version: '8.2'
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: |
|
||||||
|
cd server
|
||||||
|
./vendor/bin/phpunit
|
||||||
|
```
|
||||||
|
|
||||||
|
### Full Integration Test (All Components)
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Integration Tests
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Server with All Components
|
||||||
|
uses: Nodarx/action-server-install@v2
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
install-php: 'true'
|
||||||
|
install-nginx: 'true'
|
||||||
|
node-version: '20'
|
||||||
|
php-version: '8.2'
|
||||||
|
|
||||||
|
- name: Run integration tests
|
||||||
|
run: |
|
||||||
|
cd server
|
||||||
|
npm run test:integration
|
||||||
|
```
|
||||||
|
|
||||||
|
### With Custom nginx Configuration
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Install Server with nginx
|
||||||
|
uses: Nodarx/action-server-install@v2
|
||||||
|
with:
|
||||||
|
install-nginx: 'true'
|
||||||
|
nginx-config: './config/nginx.conf'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Example with All Options
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Deploy Server
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
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@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'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
### Component Selection
|
||||||
|
|
||||||
|
| Input | Description | Required | Default |
|
||||||
|
|-------|-------------|----------|---------|
|
||||||
|
| `install-node` | Install Node.js environment | No | `false` |
|
||||||
|
| `install-php` | Install PHP environment | No | `false` |
|
||||||
|
| `install-nginx` | Install nginx web server | No | `false` |
|
||||||
|
|
||||||
|
**Note:** At least one component must be enabled.
|
||||||
|
|
||||||
|
### General Configuration
|
||||||
|
|
||||||
|
| Input | Description | Required | Default |
|
||||||
|
|-------|-------------|----------|---------|
|
||||||
|
| `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 | `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.2` |
|
||||||
|
| `php-extensions` | Comma-separated list of PHP extensions to install | No | `mbstring, xml, ctype, json, curl, zip` |
|
||||||
|
|
||||||
|
### nginx Configuration
|
||||||
|
|
||||||
|
| Input | Description | Required | Default |
|
||||||
|
|-------|-------------|----------|---------|
|
||||||
|
| `nginx-config` | Path to nginx configuration file | No | `''` |
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
| Output | Description |
|
||||||
|
|--------|-------------|
|
||||||
|
| `install-status` | Status of the installation (success/failure) |
|
||||||
|
| `install-path` | Path where the server was installed |
|
||||||
|
| `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) |
|
||||||
|
|
||||||
|
## 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@v2
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Pin to specific versions**: Use commit SHA or version tag
|
||||||
|
```yaml
|
||||||
|
uses: Nodarx/action-server-install@v2.0.0
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Cache dependencies**: Combine with caching for faster builds
|
||||||
|
```yaml
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('server/package-lock.json') }}
|
||||||
|
|
||||||
|
- uses: Nodarx/action-server-install@v2
|
||||||
|
with:
|
||||||
|
install-node: 'true'
|
||||||
|
```
|
||||||
|
|
||||||
|
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:
|
||||||
|
include:
|
||||||
|
- name: Node Tests
|
||||||
|
install-node: 'true'
|
||||||
|
install-php: 'false'
|
||||||
|
- name: PHP Tests
|
||||||
|
install-node: 'false'
|
||||||
|
install-php: 'true'
|
||||||
|
- name: Integration Tests
|
||||||
|
install-node: '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
|
||||||
|
|
||||||
|
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
|
||||||
264
action.yml
Normal file
264
action.yml
Normal file
@@ -0,0 +1,264 @@
|
|||||||
|
name: 'Server Install Action'
|
||||||
|
description: 'Clone Nodarx server repository and install Node.js, PHP, and/or nginx based on test requirements'
|
||||||
|
author: 'Nodarx'
|
||||||
|
|
||||||
|
branding:
|
||||||
|
icon: 'server'
|
||||||
|
color: 'blue'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
server-path:
|
||||||
|
description: 'Path where the server will be cloned/installed'
|
||||||
|
required: false
|
||||||
|
default: './server'
|
||||||
|
install-node:
|
||||||
|
description: 'Install Node.js environment'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
install-php:
|
||||||
|
description: 'Install PHP environment'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
install-nginx:
|
||||||
|
description: 'Install nginx web server'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
install-dependencies:
|
||||||
|
description: 'Whether to install dependencies (npm/composer)'
|
||||||
|
required: false
|
||||||
|
default: 'true'
|
||||||
|
node-version:
|
||||||
|
description: 'Node.js version to use (if install-node is true)'
|
||||||
|
required: false
|
||||||
|
default: '20'
|
||||||
|
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
|
||||||
|
default: '8.2'
|
||||||
|
php-extensions:
|
||||||
|
description: 'Comma-separated list of PHP extensions to install'
|
||||||
|
required: false
|
||||||
|
default: 'mbstring, xml, ctype, json, curl, zip'
|
||||||
|
web-config:
|
||||||
|
description: 'Path to nginx configuration file (optional)'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
build-command:
|
||||||
|
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: ''
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
install-status:
|
||||||
|
description: 'Status of the installation (success/failure)'
|
||||||
|
value: ${{ steps.install.outputs.status }}
|
||||||
|
install-path:
|
||||||
|
description: 'Path where the server was installed'
|
||||||
|
value: ${{ steps.install.outputs.path }}
|
||||||
|
node-installed:
|
||||||
|
description: 'Whether Node.js was installed'
|
||||||
|
value: ${{ steps.install.outputs.node_installed }}
|
||||||
|
php-installed:
|
||||||
|
description: 'Whether PHP was installed'
|
||||||
|
value: ${{ steps.install.outputs.php_installed }}
|
||||||
|
nginx-installed:
|
||||||
|
description: 'Whether nginx was installed'
|
||||||
|
value: ${{ steps.install.outputs.nginx_installed }}
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: 'composite'
|
||||||
|
steps:
|
||||||
|
- name: Validate inputs
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Validating inputs"
|
||||||
|
|
||||||
|
# Validate at least one component is enabled
|
||||||
|
if [ "${{ inputs.install-node }}" != "true" ] && \
|
||||||
|
[ "${{ inputs.install-php }}" != "true" ] && \
|
||||||
|
[ "${{ inputs.install-nginx }}" != "true" ]; then
|
||||||
|
echo "::error::At least one component must be enabled (install-node, install-php, or install-nginx)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Server path: ${{ inputs.server-path }}"
|
||||||
|
echo "Components to install:"
|
||||||
|
[ "${{ inputs.install-node }}" == "true" ] && echo " ✓ Node.js ${{ inputs.node-version }} (${{ inputs.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: 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.js
|
||||||
|
if: inputs.install-node == 'true'
|
||||||
|
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
|
||||||
|
with:
|
||||||
|
php-version: ${{ inputs.php-version }}
|
||||||
|
extensions: ${{ inputs.php-extensions }}
|
||||||
|
tools: composer:v2
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Install nginx
|
||||||
|
if: inputs.install-web-server == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Installing nginx"
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get install -y nginx
|
||||||
|
echo "nginx installed successfully"
|
||||||
|
nginx -v
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Configure nginx
|
||||||
|
if: inputs.install-web-server == 'true' && inputs.nginx-config != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Configuring nginx"
|
||||||
|
|
||||||
|
if [ -f "${{ inputs.nginx-config }}" ]; then
|
||||||
|
sudo cp "${{ inputs.nginx-config }}" /etc/nginx/sites-available/default
|
||||||
|
sudo nginx -t
|
||||||
|
sudo systemctl reload nginx
|
||||||
|
echo "nginx configured successfully"
|
||||||
|
else
|
||||||
|
echo "::warning::nginx config file not found: ${{ inputs.nginx-config }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Start nginx
|
||||||
|
if: inputs.install-web-server == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Starting nginx"
|
||||||
|
sudo systemctl start nginx
|
||||||
|
sudo systemctl status nginx --no-pager || true
|
||||||
|
echo "nginx started successfully"
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Install Node.js dependencies
|
||||||
|
if: inputs.install-node == 'true' && inputs.install-dependencies == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Installing Node.js dependencies"
|
||||||
|
cd "${{ inputs.server-path }}"
|
||||||
|
|
||||||
|
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
|
||||||
|
if: inputs.install-php == 'true' && inputs.install-dependencies == 'true'
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Installing PHP dependencies"
|
||||||
|
cd "${{ inputs.server-path }}"
|
||||||
|
|
||||||
|
if [ -f "composer.json" ]; then
|
||||||
|
composer install --no-dev --optimize-autoloader
|
||||||
|
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::"
|
||||||
|
|
||||||
|
- name: Run build command
|
||||||
|
if: inputs.build-command != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Running build command"
|
||||||
|
cd "${{ inputs.server-path }}"
|
||||||
|
${{ inputs.build-command }}
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Run post-install script
|
||||||
|
if: inputs.post-install-script != ''
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "::group::Running post-install script"
|
||||||
|
cd "${{ inputs.server-path }}"
|
||||||
|
chmod +x "${{ inputs.post-install-script }}"
|
||||||
|
"${{ inputs.post-install-script }}"
|
||||||
|
echo "::endgroup::"
|
||||||
|
|
||||||
|
- name: Set outputs
|
||||||
|
id: install
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "status=success" >> $GITHUB_OUTPUT
|
||||||
|
echo "path=${{ inputs.server-path }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "node_installed=${{ inputs.install-node }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "php_installed=${{ inputs.install-php }}" >> $GITHUB_OUTPUT
|
||||||
|
echo "nginx_installed=${{ inputs.install-nginx }}" >> $GITHUB_OUTPUT
|
||||||
123
scripts/health-check.sh
Normal file
123
scripts/health-check.sh
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Health check script
|
||||||
|
# Verifies that the server installation is successful
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SERVER_PATH="${1:-.}"
|
||||||
|
CHECK_NODE="${2:-false}"
|
||||||
|
CHECK_PHP="${3:-false}"
|
||||||
|
CHECK_NGINX="${4:-false}"
|
||||||
|
|
||||||
|
echo "Running health check for server at: $SERVER_PATH"
|
||||||
|
|
||||||
|
cd "$SERVER_PATH"
|
||||||
|
|
||||||
|
# Check if server directory exists
|
||||||
|
if [ ! -d "." ]; then
|
||||||
|
echo "✗ Server directory not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "✓ Server directory exists"
|
||||||
|
|
||||||
|
# Check Node.js installation
|
||||||
|
if [ "$CHECK_NODE" == "true" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Checking Node.js installation..."
|
||||||
|
|
||||||
|
if command -v node &> /dev/null; then
|
||||||
|
NODE_VERSION=$(node --version)
|
||||||
|
echo "✓ Node.js installed: $NODE_VERSION"
|
||||||
|
else
|
||||||
|
echo "✗ Node.js not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v npm &> /dev/null; then
|
||||||
|
NPM_VERSION=$(npm --version)
|
||||||
|
echo "✓ npm installed: $NPM_VERSION"
|
||||||
|
else
|
||||||
|
echo "✗ npm not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if package.json exists
|
||||||
|
if [ -f "package.json" ]; then
|
||||||
|
echo "✓ package.json found"
|
||||||
|
|
||||||
|
# Check if node_modules exists
|
||||||
|
if [ -d "node_modules" ]; then
|
||||||
|
echo "✓ Node.js dependencies installed"
|
||||||
|
else
|
||||||
|
echo "✗ Node.js dependencies not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check PHP installation
|
||||||
|
if [ "$CHECK_PHP" == "true" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Checking PHP installation..."
|
||||||
|
|
||||||
|
if command -v php &> /dev/null; then
|
||||||
|
PHP_VERSION=$(php --version | head -n 1)
|
||||||
|
echo "✓ PHP installed: $PHP_VERSION"
|
||||||
|
else
|
||||||
|
echo "✗ PHP not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v composer &> /dev/null; then
|
||||||
|
COMPOSER_VERSION=$(composer --version | head -n 1)
|
||||||
|
echo "✓ Composer installed: $COMPOSER_VERSION"
|
||||||
|
else
|
||||||
|
echo "✗ Composer not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if composer.json exists
|
||||||
|
if [ -f "composer.json" ]; then
|
||||||
|
echo "✓ composer.json found"
|
||||||
|
|
||||||
|
# Check if vendor directory exists
|
||||||
|
if [ -d "vendor" ]; then
|
||||||
|
echo "✓ PHP dependencies installed"
|
||||||
|
else
|
||||||
|
echo "✗ PHP dependencies not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check nginx installation
|
||||||
|
if [ "$CHECK_NGINX" == "true" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Checking nginx installation..."
|
||||||
|
|
||||||
|
if command -v nginx &> /dev/null; then
|
||||||
|
NGINX_VERSION=$(nginx -version 2>&1)
|
||||||
|
echo "✓ nginx installed: $NGINX_VERSION"
|
||||||
|
else
|
||||||
|
echo "✗ nginx not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if nginx is running
|
||||||
|
if systemctl is-active --quiet nginx 2>/dev/null || pgrep nginx > /dev/null 2>&1; then
|
||||||
|
echo "✓ nginx is running"
|
||||||
|
else
|
||||||
|
echo "⚠ nginx is installed but not running"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check nginx configuration
|
||||||
|
if sudo nginx -t &> /dev/null; then
|
||||||
|
echo "✓ nginx configuration is valid"
|
||||||
|
else
|
||||||
|
echo "⚠ nginx configuration may have issues"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "✓ Health check passed!"
|
||||||
|
exit 0
|
||||||
22
scripts/post-install.sh
Normal file
22
scripts/post-install.sh
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Example post-install script
|
||||||
|
# This script runs after dependencies are installed
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Running post-installation tasks..."
|
||||||
|
|
||||||
|
# Example: Set permissions
|
||||||
|
# chmod +x ./server/bin/*
|
||||||
|
|
||||||
|
# Example: Create necessary directories
|
||||||
|
# mkdir -p ./server/logs
|
||||||
|
# mkdir -p ./server/tmp
|
||||||
|
|
||||||
|
# Example: Run database migrations
|
||||||
|
# npm run migrate
|
||||||
|
|
||||||
|
# Example: Clear cache
|
||||||
|
# npm run cache:clear
|
||||||
|
|
||||||
|
echo "Post-installation completed successfully!"
|
||||||
Reference in New Issue
Block a user