sonntagnacht / deploy-bundle
用于部署 symfony 2.8+ 项目的命令
1.0.5
2018-05-29 06:00 UTC
Requires
- php: >=5.6
- sonntagnacht/toolbox-bundle: ^0.2
- vierbergenlars/php-semver: 3.0.*
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-15 03:55:00 UTC
README
安装
$ composer require sonntagnacht/deploy-bundle 1.0.1
配置
SNDeployBundle 的主要配置
app/config.yml
sn_deploy: composer: "/usr/bin/composer" default_environment: "prod" # default null environments: prod: # host address of webserver ssh_host: example.com # ssh-user for webserver ssh_user: ftp-user # ssh-port for rsync ssh_port: 22 # default 22 # absolute path of web app on remote server remote_app_dir: /var/www/html # to permit deploy only from one branch branch: "production" # default null # repository version has to be newer then remote version - uses semver check_version: true # default true # customize the rsync transfer settings, parameters below are the default ones rsync_options: "--info=progress2 --delete -a" # include these files & direcotires, creates a rsync.inlcude file in /tmp/sn-deploy-rsync.include # which is used for deployment include: [] # exclude these files & directories, creates a rsync.exclude file in /tmp/sn-deploy-rsync.exclude # which is used for deployment exclude: [] # cache clear commands cache_clear: - "php bin/console cache:clear --prod" # local commands before project will upload pre_upload: [] # local commands after project has been uploaded post_upload: [] # remote commands before project will upload pre_upload_remote: [] # remote commands after project has been uploaded post_upload_remote: []
要在 twig 中获取版本信息,您需要将 sn_deploy.twig
服务添加到 twig 全局变量中。
twig:
globals:
sn_deploy: "@sn_deploy.twig"
用法
命令
使用 sn:deploy [prod|test|dev]
将您的项目部署到您的 web 服务器。
如果您想上传一个不带新版本的修复程序,请使用 sn:deploy [prod|test|dev] --hotfix
完整配置示例
sn_deploy: composer: "/usr/local/bin/composer" environments: prod: branch: "production" ssh_host: 12.34.56.78 ssh_user: www-data remote_app_dir: /var/www/vhosts/mydomain.com check_version: true cache_clear: - "php bin/console redis:flushall -n" - "php bin/console cache:clear" - "php bin/console cache:clear -e prod" exclude: - ".DS_Store" - "data" - "var/cache" - "var/logs" - "var/sessions" pre_upload: - "bin/scripts/install_assets.sh" - "bin/scripts/generate_assets.sh" pre_upload_remote: - "/opt/plesk/php/7.0/bin/php bin/console lexik:maintenance:lock" post_upload_remote: - "/opt/plesk/php/7.0/bin/php bin/console doctrine:migrations:migrate" - "/opt/plesk/php/7.0/bin/php bin/console doctrine:schema:update --dump-sql --force" - "/opt/plesk/php/7.0/bin/php bin/console fos:elastica:populate" - "/opt/plesk/php/7.0/bin/php bin/console lexik:maintenance:unlock" - "cat web/.htaccess_prod >> web/.htaccess" test: ssh_host: 12.34.56.78 ssh_user: www-data remote_app_dir: /var/www/vhosts/test.mydomain.com check_version: false cache_clear: - "php bin/console redis:flushall -n" - "php bin/console cache:clear" - "php bin/console cache:clear -e prod" exclude: - ".DS_Store" - "data" - "var/cache" - "var/logs" - "var/sessions" pre_upload: - "bin/scripts/install_assets.sh" - "bin/scripts/generate_assets.sh" pre_upload_remote: - "/opt/plesk/php/7.0/bin/php bin/console lexik:maintenance:lock" post_upload_remote: - "/opt/plesk/php/7.0/bin/php bin/console doctrine:migrations:migrate" - "/opt/plesk/php/7.0/bin/php bin/console doctrine:schema:update --dump-sql --force" - "/opt/plesk/php/7.0/bin/php bin/console fos:elastica:populate" - "/opt/plesk/php/7.0/bin/php bin/console lexik:maintenance:unlock" - "cat web/.htaccess_test >> web/.htaccess"
Twig 变量
获取当前部署版本使用 {{ sn_deploy.version }}
获取上次更新的时间戳使用 {{ sn_deploy.timestamp|date('Y/m/d H:i') }}
获取当前部署的提交使用 {{ sn_deploy.commit }}