81 lines
2.3 KiB
YAML
81 lines
2.3 KiB
YAML
name: Deploy Laravel Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- "server/**"
|
|
- ".nvmrc"
|
|
- ".gitea/workflows/server-deploy.yml"
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0
|
|
env:
|
|
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
|
|
MYSQL_DATABASE: new_pet_test
|
|
ports:
|
|
- 3306:3306
|
|
options: >-
|
|
--health-cmd="mysqladmin ping"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=10
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: "8.2"
|
|
extensions: bcmath, curl, dom, fileinfo, intl, mbstring, pdo_mysql, redis, xml, zip
|
|
coverage: none
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version-file: .nvmrc
|
|
cache: npm
|
|
cache-dependency-path: server/package-lock.json
|
|
- name: Install server dependencies
|
|
working-directory: server
|
|
run: |
|
|
composer validate --no-check-publish
|
|
composer install --no-interaction --prefer-dist
|
|
npm ci
|
|
- name: Prepare the test environment
|
|
working-directory: server
|
|
run: |
|
|
cp .env.test .env.testing
|
|
php artisan key:generate --env=testing
|
|
- name: Run HTTP API tests
|
|
working-directory: server
|
|
run: php artisan test
|
|
- name: Build server assets
|
|
working-directory: server
|
|
run: npm run build
|
|
- uses: actions/upload-artifact@v4
|
|
with:
|
|
name: server-build
|
|
path: server/public/build
|
|
if-no-files-found: error
|
|
|
|
deploy:
|
|
needs: verify
|
|
runs-on: production
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
name: server-build
|
|
path: server/public/build
|
|
- uses: https://gitea.neatcn.com/pets/deployment-toolkit/actions/laravel-release@v1
|
|
with:
|
|
source-dir: server
|
|
deploy-root: ${{ vars.SERVER_DEPLOY_ROOT }}
|
|
container-deploy-root: ${{ vars.SERVER_CONTAINER_DEPLOY_ROOT }}
|
|
php-container: ${{ vars.SERVER_PHP_CONTAINER }}
|
|
healthcheck-url: ${{ vars.SERVER_HEALTHCHECK_URL }}
|
|
backup-command: ${{ secrets.SERVER_BACKUP_COMMAND }}
|
|
release-id: ${{ gitea.sha }}
|