利用Bitbucket的Deployments在git推送后自动部署PHP线上代码
在项目根目录下新建bitbucket-pipelines.yml,填入以下内容
image: dotsunited/git-ftp:latest
pipelines:
default: # Pipelines that are triggered manually via the Bitbucket GUI
- step:
caches:
- composer
script:
- git ftp push --auto-init -v --user $FTP_USER --passwd $FTP_PASSWORD $FTP_HOST --all
branches: # Automated triggers on commits to branches
master: # -- When committing to master branch
- step:
deployment: production
#caches:
# - composer
script:
- git ftp push --auto-init -v --user $FTP_USER --passwd $FTP_PASSWORD $FTP_HOST
dev: # -- When committing to dev branch
- step:
deployment: test
script:
- git ftp push --auto-init -v --user $FTP_DEV_USER --passwd $FTP_DEV_PASSWORD $FTP_DEV_HOST
# - git ftp push --auto-init -v --syncroot public/ --user $FTP_DEPLOY_USER --passwd $FTP_DEPLOY_PASSWORD $FTP_DEPLOY_HOST
然后在设置中设置$FTP_USERNAME,$FTP_PASSWORD和$FTP_HOST变量,当推送到master和dev分支时,就会自动部署到指定服务器。如果需要手工触发自动部署,进入Cloud > Commits > Commit Number > Run Pipeline > Custom:Init
评论