config/drafts/ci-templates/README.md
2026-02-02 21:50:19 +00:00

126 lines
3.1 KiB
Markdown

# Cloonar CI Templates
Shared CI/CD templates for Cloonar projects.
## Contents
```
.forgejo/workflows/
typo3-deploy.yaml # Simple deployment workflow
typo3-staged-deploy.yaml # Staged deployment with E2E tests
deployer/
typo3-recipe.php # Shared Deployer configuration
examples/
project-deploy.php # Example project deploy.php
project-servers.yaml # Example servers.yaml
project-workflow-*.yaml # Example workflow files
```
## Quick Start
### 1. Update your project's `build/deploy.php`
Replace your entire deploy.php with:
```php
<?php
namespace Deployer;
// Import shared recipe
require 'https://git.cloonar.com/Cloonar/ci-templates/raw/branch/main/deployer/typo3-recipe.php';
import(__DIR__ . '/servers.yaml');
host('stage')->set('cachetool', '/var/run/phpfpm/myproject.cloonar.dev.sock');
host('production')->set('cachetool', '/var/run/phpfpm/myproject.at.sock');
```
### 2. Keep your `build/servers.yaml` (project-specific)
```yaml
hosts:
stage:
hostname: web-arm.cloonar.com
remote_user: myproject_cloonar_dev
deploy_path: ~/
# ... rest of config
```
### 3. Update your workflow
Replace `.forgejo/workflows/deploy.yaml` with:
**Simple deployment:**
```yaml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
uses: Cloonar/ci-templates/.forgejo/workflows/typo3-deploy.yaml@main
with:
target: stage
php_version: '8.3'
secrets:
deploy_key: ${{ secrets.STAGE_KEY }}
```
**Staged deployment with tests:**
```yaml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
uses: Cloonar/ci-templates/.forgejo/workflows/typo3-staged-deploy.yaml@main
with:
stage_url: https://myproject.cloonar.dev
run_e2e_tests: true
secrets:
stage_key: ${{ secrets.STAGE_KEY }}
prod_key: ${{ secrets.PROD_KEY }}
```
## Workflow Options
### typo3-deploy.yaml
| Input | Default | Description |
|-------|---------|-------------|
| `target` | required | `stage` or `production` |
| `task` | `deploy` | Deployer task (`deploy`, `release:create`, `release:switch`) |
| `php_version` | `8.3` | PHP version |
| `run_tests` | `false` | Run PHPStan/Psalm before deploy |
| `build_frontend` | `false` | Run `npm ci && npm run build` |
### typo3-staged-deploy.yaml
| Input | Default | Description |
|-------|---------|-------------|
| `stage_url` | required | URL for E2E tests |
| `php_version` | `8.3` | PHP version |
| `run_e2e_tests` | `true` | Run Playwright tests after stage deploy |
| `e2e_path` | `tests/e2e` | Path to E2E test directory |
| `deploy_production` | `false` | Auto-deploy to prod after tests pass |
## Deployer Tasks
The shared recipe provides these tasks:
- `release:create <target>` - Upload release without switching (for staged deploys)
- `release:switch <target>` - Switch to uploaded release
- `deploy <target>` - Full deploy (create + switch)
## Migration Checklist
- [ ] Create `Cloonar/ci-templates` repo with these files
- [ ] Update project's `build/deploy.php` to use shared recipe
- [ ] Update project's `.forgejo/workflows/` to use reusable workflows
- [ ] Delete old `.drone.yml` files
- [ ] Test on one project first (e.g., gbv-aktuell)