From 062c917c302c792352ee42738cc8d8990bb022fc Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 3 Nov 2023 18:07:10 +0100 Subject: [PATCH] add ci --- .woodpecker/build.yml | 68 ++++++++++++++++++++++++++++++++++++++++++ .woodpecker/deploy.yml | 25 ++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 .woodpecker/build.yml create mode 100644 .woodpecker/deploy.yml diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml new file mode 100644 index 0000000..1210c36 --- /dev/null +++ b/.woodpecker/build.yml @@ -0,0 +1,68 @@ +variables: + - &volumes + - node16_cache:/root/.npm + - /data/${CI_REPO}:/builds + +when: + event: [push, pull_request, tag, manual] + branch: [master, master-*, develop, develop-*, feature/*] + +steps: + 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' + + db-create: + image: mariadb:10.3 + secrets: [mysqldump] + commands: + - mysql -hdb -uroot -proot -e "CREATE DATABASE app" + + 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 + + php-composer: + image: deblan/php:8.1 + commands: + - apt-get update && apt-get -y install git + - composer install --no-scripts + + php-build: + image: deblan/php:8.1 + environment: + - PHP=php + commands: + - ./bin/doctrine-migrate + - php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json + + node-build: + image: node:16-alpine + commands: + - make asset + + security-check: + image: gitnet.fr/deblan/osv-detector:v0.9 + commands: + - osv-detector composer.lock yarn.lock + failure: ignore + + cache-build: + image: deblan/mage + volumes: *volumes + commands: + - cd /builds + - rsync -az "$CI_WORKSPACE/" "$CI_COMMIT_SHA" + +services: + db: + image: mariadb:10.3 + environment: + - MARIADB_ROOT_PASSWORD=root + +volumes: + node16_cache: diff --git a/.woodpecker/deploy.yml b/.woodpecker/deploy.yml new file mode 100644 index 0000000..b9b25bc --- /dev/null +++ b/.woodpecker/deploy.yml @@ -0,0 +1,25 @@ +variables: + - &volumes + - /data/deblan/deblan.io-murph:/builds + +when: + event: [deployment] + +skip_clone: true + +steps: + app-deploy: + image: deblan/mage + secrets: [ssh_user, ssh_host, ssh_priv_key, app_directory] + volumes: *volumes + commands: + - cd "/builds/$CI_COMMIT_SHA" + - mkdir "$HOME/.ssh" + - echo "$SSH_PRIV_KEY" > "$HOME/.ssh/id_ed25519" + - chmod 700 "$HOME/.ssh" + - chmod 600 "$HOME/.ssh/id_ed25519" + - 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 + - mage deploy "$CI_PIPELINE_DEPLOY_TARGET"