- Integrated ftp, sftp, ssh2, aliyunOss.
- Uses a configuration file with yaml format.
- Reasonable notification configuration, real-time deployment status.
- Suitable for automatic build
npm i rishiqing-deploy
In rishiqing-deploy, we provide four kinds of task: build, resource, fileReplace, endBuild. All tasks are executed in the order of : build -> resource -> fileReplace -> endBuild. Once the error, the subsequent tasks will stop.
We also intend to provide types notification tools, now only bearychat, but we will add more later.
Execute at the very beginning. all commands inside build will been executed. once the error, the task will stop.
Resource is used to upload files to servers. Use different tools to upload. This will covere the file of the same name.
FileReplace is just like resource, but it is used to replace the entry files, such as index.html
. Before upload, it will rename the file/directory which the target specified, then upload the local file/directory as the name of target specified.
EndBuild is used to do some work after uploads, such as clean directory.
Without install rishiqing-deploy globally, you can install it locally, then add a script field to your package.json
{
"script": {
"rd": "rishiqing-deploy"
}
}
When you execute npm run rd
, the command will automatic load a file named .rishiqing-deploy.yml
for configuration. you can also customize by npm run rd -- --config=YOUR_CONFIG_FILE_NAME
.
Configuration file is NODE_ENV
friendly, you can set the environment variable NODE_ENV
or npm run rd -- --env=production
to define the environment. once the environment is defined, the default configure will been covered by it.
default: # the default config
notify:
title: 'rishiqing-deploy' # the title of notification, default is rishiqing-deploy
nodes: # define notification node
- 'after-build' # after execute all build commands
- 'one-build' # after one build command
- 'one-upload' # in resource or fileReplace task, after a uploading
- 'one-file-upload' # after one file uploaded
- 'one-resource' # after one resource task
- 'resource' # after all resources tasks
- 'one-file-replace' # after one fileReplace task
- 'file-replace' # after all fileReplace tasks
- 'statistics' # send the statistics information
- 'success' # ending with success
- 'error' # when error throwing out
- 'deploy-log' # generate deploy log after build
list:
- type: bearychat # bearychat notification
param:
hook: '' # bearychat incoming hook
user: 'qinyang' # the user who you want to notify
title: '' # coverd the title as previously defined
channel: 'automaitc-deploy' # the channel which you want to notify. note: channel has priority over user
nodes: # filter the nodes those you need
- 'one-resource'
- 'resource'
- 'one-file-replace'
- 'file-replace'
- 'success'
- type: dingtalk # dingding notification
param:
hook: 'https://oapi.dingtalk.com/robot/send?access_token=xxxxx' # dingtalk notification hook
deployLog: # deploy log
match: '/^log--/' # match commit message begin with log--
beforeSha: 1fcba37592714962 # default is process.env.CI_COMMIT_BEFORE_SHA
tagPrefix: master-deploy- # default is master-deploy-
tagMatch: '/master-deploy-v(0|[1-9]\d*).(0|[1-9]\d*).(0|[1-9]\d*)/'
timeZone: 'Asia/Shanghai' # default is Asia/Shanghai
timeFormat: 'YYYY-MM-DD HH:mm' # default is YYYY-MM-DD HH:mm
branch: master # default is process.env.CI_COMMIT_REF_NAME
projectUrl: https://gitlab.com/xxx/xxx # default is process.env.CI_PROJECT_URL
replaceMatch: true # replace match with empty string
title: 'deploy log' # default is deploy log
goToLink: https://gitlab.com'
version: '0.0.1'
convert: # convert file type (now support convert yml to json)
- target: /path/to/the/file/to/be/converted
dest: /path/to/output
build: # define the build command list
- 'npm run webpack'
resource:
- dist: 'dist' # local file or directory
ignore: # the ignore list, support regexp
- 'images'
- 'index.html'
- 'manifest.json'
- '/\.map$/'
upload: # specify the upload tool. the tools specified will been executed one by one.
- type: 'aliyunOss'
param:
accessKeyId: ''
# accessKeySecret and secretAccessKey is same
# There are two because the earliest parameter is called secretAccessKey
# but after updating ali-oss, the parameter name was changed to accessKeySecret
# in order to be compatible with the previous configuration, two parameters are supported at the same time.
accessKeySecret: ''
secretAccessKey: ''
bucket: ''
# Set the region or endpoint
region: 'oss-cn-beijing'
# the priority of the endpoint is higher than the region
endpoint: 'http://oss-cn-beijing.aliyuncs.com'
prefix: ''
- type: 'ftp'
param:
host: ''
port: 21
user: ''
password: ''
path: ''
- type: 'sftp'
param:
host: ''
port: 22
username: ''
password: ''
path: ''
- type: 'ssh2' # use ssh2, you must be able to access the server through a certificate
param:
host: ''
port: 22
user: ''
path: ''
fileReplace:
- dist: 'dist/app.js' # local file or directory
ignore:
- ''
target: 'global.js'
upload:
- type: 'aliyunOss'
param:
accessKeyId: ''
# accessKeySecret and secretAccessKey is same
# There are two because the earliest parameter is called secretAccessKey
# but after updating ali-oss, the parameter name was changed to accessKeySecret
# in order to be compatible with the previous configuration, two parameters are supported at the same time.
accessKeySecret: ''
secretAccessKey: ''
bucket: ''
# Set the region or endpoint
region: 'oss-cn-beijing'
# the priority of the endpoint is higher than the region
endpoint: 'http://oss-cn-beijing.aliyuncs.com'
prefix: ''
- type: 'ftp'
param:
host: ''
port: 21
user: ''
password: ''
path: ''
- type: 'sftp'
param:
host: ''
port: 22
username: ''
password: ''
path: ''
- type: 'ssh2'
param:
host: ''
port: 22
user: ''
path: ''
endBuild:
- 'npm run clean'
production: # the production environment. will covere the defualt config
resource:
- dist: 'dist'
ignore:
- 'images'
- 'index.html'
- 'manifest.json'
- '/\\.map$/' # '\' must be '\' escaped
upload:
- type: 'sftp'
param:
host: ''
port: 22
username: ''
password: ''
path: ''
- type: 'ssh2'
param:
host: ''
port: 22
user: ''
path: ''
Copyright (c) 2014-2016 Rishiqing