@4rk/staticpages-cli 中文文档教程

发布于 4年前 浏览 24 项目主页 更新于 3年前

Staticpages CLI

这是我们的staticpages 后端 的客户端命令行界面。

Usage

  1. Install it using either npm or yarn: npm install -g @4rk/staticpages-cli
  2. Create a .env file with corresponding parameters as explained in the next section
  3. Run staticpages-cli

Configuration

配置参数使用以下优先级产生:

  1. Environment variables
  2. Environment variables placed in a .env file
  3. Command line parameters. Check -h

可用的环境变量是:

  • DEPLOY_KEY
  • DEPLOY_SERVER
  • DEPLOY_SRC

How does it work

当运行客户端时,它:

  1. Loads configuration parameters
  2. Checks whether the folder DEPLOY_SRC exists, otherwise it fails
  3. Retrieves the current git branch using git rev-parse --abbrev-ref HEAD
  4. Asks the staticpages API at DEPLOY_SERVER using DEPLOY_KEY for the rsync remote, deploy URL etc
  5. Uploads all files from DEPLOY_SRC via rsync
  6. 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

  1. Install it using either npm or yarn: npm install -g @4rk/staticpages-cli
  2. Create a .env file with corresponding parameters as explained in the next section
  3. Run staticpages-cli

Configuration

Configuration parameters originate using the following precedence:

  1. Environment variables
  2. Environment variables placed in a .env file
  3. Command line parameters. Check -h

Available environment variables are:

  • DEPLOY_KEY
  • DEPLOY_SERVER
  • DEPLOY_SRC

How does it work

When running the client, it:

  1. Loads configuration parameters
  2. Checks whether the folder DEPLOY_SRC exists, otherwise it fails
  3. Retrieves the current git branch using git rev-parse --abbrev-ref HEAD
  4. Asks the staticpages API at DEPLOY_SERVER using DEPLOY_KEY for the rsync remote, deploy URL etc
  5. Uploads all files from DEPLOY_SRC via rsync
  6. 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

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文