我对Bitbucket Pipelines有点陌生,我正在尝试设置一个NodeJS api以自动部署到数字海洋小滴,并且由于我已经尝试了两天,所以我真的很感谢一些建议!
我设法弄清楚了如何scp部署npm run build
生成的dist目录,但是我认为我需要的比服务器上的还要多吗?即node_modules,package.json等??
这些是我尝试过的一些例子。
sftp
image: node:10.16.0
pipelines:
default:
- step:
name: Build API
caches:
- node
script:
- npm install
- npm run build
- step:
name: Deploy API PRODUCTION
deployment: production
script:
- pipe: atlassian/sftp-deploy:0.4.1
variables:
USER: $USER
SERVER: $PROD_SERVER
REMOTE_PATH: '/var/www/live'
压缩
image: node:10.16.0
pipelines:
default:
- step:
name: Build API
caches:
- node
script:
- npm install
- npm run build
- tar czfv appname-api.tgz dist/ src/ node_modules/ package-lock.json package.json tsconfig.json tslint.json
artifacts:
- appname-api.tgz
- step:
name: Deploy API PRODUCTION
deployment: production
script:
- pipe: atlassian/scp-deploy:0.3.3
variables:
USER: $USER
SERVER: $PROD_SERVER
REMOTE_PATH: '/var/www/live'
LOCAL_PATH: 'appname-api.tgz'
以各种方式压缩它
tar --exclude='./git' -czfv appname-api.tgz ./
我想我可以做一个deploy.sh
来进行git pull,但是我的存储库是私有的,这意味着对于每台服务器,我都必须添加ssh密钥等,因此并不理想。.