119 lines
3.6 KiB
YAML
119 lines
3.6 KiB
YAML
pipeline:
|
|
db-wait:
|
|
image: gitnet.fr/deblan/timeout:latest
|
|
commands:
|
|
- /bin/timeout -t 30 -v -c 'while true; do nc -z -v db 3306 2>&1 | grep succeeded && exit 0; sleep 0.5; done'
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
db-create:
|
|
image: mariadb:10.3
|
|
secrets: [mysqldump]
|
|
commands:
|
|
- mysql -hdb -uroot -proot -e "CREATE DATABASE app"
|
|
- eval "$MYSQLDUMP" | mysql -hdb -uroot -proot app
|
|
when:
|
|
branch: [master, master-*, develop, develop-*]
|
|
event: [push, pull_request]
|
|
|
|
app-config:
|
|
image: deblan/php:8.1
|
|
commands:
|
|
- echo APP_ENV=prod >> .env.local
|
|
- echo APP_SECRET=$(openssl rand -hex 32) >> .env.local
|
|
- echo DATABASE_URL=mysql://root:root@db/app >> .env.local
|
|
when:
|
|
branch: [master, master-*, develop, develop-*]
|
|
event: [push, pull_request]
|
|
|
|
php-composer:
|
|
image: deblan/php:8.1
|
|
commands:
|
|
- apt-get update && apt-get -y install git
|
|
- composer install --no-scripts
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
db-migrate:
|
|
image: deblan/php:8.1
|
|
environment:
|
|
- PHP=php
|
|
commands:
|
|
- ./bin/doctrine-migrate
|
|
when:
|
|
branch: [master, master-*, develop, develop-*, feature/*]
|
|
event: [push, pull_request]
|
|
|
|
app-jsroutes:
|
|
image: deblan/php:8.1
|
|
commands:
|
|
- php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json
|
|
when:
|
|
branch: [master, master-*, develop, develop-*, feature/*]
|
|
event: [push, pull_request]
|
|
|
|
node-build:
|
|
image: node:16-alpine
|
|
environment:
|
|
- CPU_COUNT=3
|
|
commands:
|
|
- apk add --no-cache git
|
|
- npm install -g svg2ttf ttf2eot ttf2woff2
|
|
- svg2ttf assets/fonts/deblan/src/deblan-icon.svg assets/fonts/deblan/deblan-icon.ttf
|
|
- cat assets/fonts/deblan/deblan-icon.ttf | ttf2woff2 > assets/fonts/deblan/deblan-icon.woff2
|
|
- ttf2eot assets/fonts/deblan/deblan-icon.ttf assets/fonts/deblan/deblan-icon.eot
|
|
- yarn
|
|
- test -f public/js/fos_js_routes.json || echo "{}" > public/js/fos_js_routes.json
|
|
- npm run build
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
security-check:
|
|
image: gitnet.fr/deblan/osv-detector:v0.9
|
|
commands:
|
|
- osv-detector composer.lock yarn.lock
|
|
failure: ignore
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
create-artifact:
|
|
image: alpine:latest
|
|
volumes:
|
|
- /var/www/html/artifacts:/var/www/html/artifacts
|
|
commands:
|
|
- ARTIFACT_PATH="/var/www/html/artifacts/deblan/deblan.io-murph/$CI_COMMIT_BRANCH"
|
|
- test -d && rm -fr "$ARTIFACT_PATH"
|
|
- mkdir -p "$ARTIFACT_PATH"
|
|
- cp -R * .* "$ARTIFACT_PATH"
|
|
when:
|
|
event: [push, pull_request]
|
|
|
|
app-deploy:
|
|
image: deblan/php:8.1
|
|
secrets: [ssh_user, ssh_host, ssh_priv_key, app_directory]
|
|
volumes:
|
|
- /var/www/html/artifacts:/var/www/html/artifacts
|
|
commands:
|
|
- cd "/var/www/html/artifacts/deblan/deblan.io-murph/$CI_COMMIT_BRANCH"
|
|
- ls -lah
|
|
- exit 1
|
|
- apt-get update && apt-get -y install rsync openssh-client
|
|
- mkdir "$HOME/.ssh"
|
|
- echo "$SSH_PRIV_KEY" > "$HOME/.ssh/id_ed25519"
|
|
- chmod 700 "$HOME/.ssh"
|
|
- chmod 600 "$HOME/.ssh/id_ed25519"
|
|
- composer global require andres-montanez/magallanes
|
|
- cp .mage.yml.dist .mage.yml
|
|
- sed -i "s/ssh_user/$SSH_USER/g" .mage.yml
|
|
- sed -i "s/ssh_host/$SSH_HOST/g" .mage.yml
|
|
- sed -i "s#app_directory#$APP_DIRECTORY#g" .mage.yml
|
|
- /root/.config/composer/vendor/bin/mage deploy "$CI_BUILD_DEPLOY_TARGET"
|
|
when:
|
|
event: [deployment]
|
|
|
|
services:
|
|
db:
|
|
image: mariadb:10.3
|
|
environment:
|
|
- MARIADB_ROOT_PASSWORD=root
|