@4rk/staticpages-cli 中文文档教程
Staticpages CLI
这是我们的staticpages 后端 的客户端命令行界面。
Usage
- Install it using either npm or yarn:
npm install -g @4rk/staticpages-cli
- Create a
.env
file with corresponding parameters as explained in the next section - Run
staticpages-cli
Configuration
配置参数使用以下优先级产生:
- Environment variables
- Environment variables placed in a
.env
file - Command line parameters. Check
-h
可用的环境变量是:
DEPLOY_KEY
DEPLOY_SERVER
DEPLOY_SRC
How does it work
当运行客户端时,它:
- Loads configuration parameters
- Checks whether the folder
DEPLOY_SRC
exists, otherwise it fails - Retrieves the current git branch using
git rev-parse --abbrev-ref HEAD
- Asks the staticpages API at
DEPLOY_SERVER
usingDEPLOY_KEY
for the rsync remote, deploy URL etc - Uploads all files from
DEPLOY_SRC
via rsync - Displays the upload URL
GitLab CI dynamic environment URLs
为了在部署后在 GitLab 中自动创建一个新的动态环境 URL,CLI 自动创建一个文件 deploy.env
当检测到在 GitLab CI 中运行时。 集成到您的管道中的工作方式如下:
deploy:
script:
- yarn build
- staticpages-cli
artifacts:
reports:
dotenv: deploy.env
environment:
name: review/$CI_COMMIT_REF_SLUG
url: $DEPLOYMENT_URL
on_stop: delete_deploy
auto_stop_in: 2 weeks
# delete deployment on environment stop
delete_deploy:
script:
- "staticpages-cli --delete"
when: manual
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
另请参阅 在作业完成后设置动态环境 URL。
Other modes
有一个 --delete
模式可以从远程删除部署。
有一个 --debug
模式可以启用详细日志记录。
License
请参阅许可证
Staticpages CLI
This is the client-side command line interface for our staticpages backend.
Usage
- Install it using either npm or yarn:
npm install -g @4rk/staticpages-cli
- Create a
.env
file with corresponding parameters as explained in the next section - Run
staticpages-cli
Configuration
Configuration parameters originate using the following precedence:
- Environment variables
- Environment variables placed in a
.env
file - Command line parameters. Check
-h
Available environment variables are:
DEPLOY_KEY
DEPLOY_SERVER
DEPLOY_SRC
How does it work
When running the client, it:
- Loads configuration parameters
- Checks whether the folder
DEPLOY_SRC
exists, otherwise it fails - Retrieves the current git branch using
git rev-parse --abbrev-ref HEAD
- Asks the staticpages API at
DEPLOY_SERVER
usingDEPLOY_KEY
for the rsync remote, deploy URL etc - Uploads all files from
DEPLOY_SRC
via rsync - Displays the upload URL
GitLab CI dynamic environment URLs
In order to automatically create a new dynamic environment URL in GitLab after deployment, the CLI automatically creates a file deploy.env
when detecting to be run within GitLab CI. Integration into your pipeline works as follows:
deploy:
script:
- yarn build
- staticpages-cli
artifacts:
reports:
dotenv: deploy.env
environment:
name: review/$CI_COMMIT_REF_SLUG
url: $DEPLOYMENT_URL
on_stop: delete_deploy
auto_stop_in: 2 weeks
# delete deployment on environment stop
delete_deploy:
script:
- "staticpages-cli --delete"
when: manual
environment:
name: review/$CI_COMMIT_REF_SLUG
action: stop
See also Set dynamic environment URLs after a job finishes.
Other modes
There is a --delete
mode that removes the deployment from the remote.
There is a --debug
mode to enable verbose logging.
License
See LICENSE