ryangjchandler / forge-previewer
使用Laravel Forge为pull request创建预览部署。
v0.2.1
2023-01-13 10:35 UTC
Requires
- php: ^8.0
- laravel-zero/framework: ^9.0
- laravel/forge-sdk: ^3.13
- nunomaduro/termwind: ^1.3
Requires (Dev)
- mockery/mockery: ^1.4.4
- pestphp/pest: ^1.21.1
README
此CLI旨在使用Laravel Forge为pull request和分支创建“预览”环境。
它打算在CI工具(如GitHub Actions)内部使用,以自动在Forge上创建与您的pull request分支连接的网站,一旦pull request合并,CLI也可以用于清理。
先决条件
在使用此工具之前,请确保您有以下内容
- 连接到Forge的服务器。
- 一个通配符子域DNS记录指向您的Forge服务器。
- Forge API令牌。
安装
使用Composer安装此包。
composer global require ryangjchandler/forge-previewer
用法
命令中有两个命令。
deploy
- 创建并部署网站。destroy
- 删除并清理网站。
deploy
deploy
命令用于执行以下操作
- 在Forge上创建网站。
- 为新的网站生成SSL证书。
- 为新的网站创建数据库。
- 启用快速部署,以便所有更改都会自动出现在预览网站上。
- 更新环境变量以指向数据库。
- 部署您的网站一次。
- 运行提供的任何附加命令。
- 如果需要,创建计划任务。
该命令接受以下标志
Description:
Deploy a branch / pull request to Laravel Forge.
Usage:
deploy [options]
Options:
--token[=TOKEN] The Forge API token.
--server[=SERVER] The ID of the target server.
--provider[=PROVIDER] The Git provider. [default: "github"]
--repo[=REPO] The name of the repository being deployed.
--branch[=BRANCH] The name of the branch being deployed.
--domain[=DOMAIN] The domain you'd like to use for deployments, e.g. mydomain.com.
--php-version[=PHP-VERSION] The version of PHP the site should use, e.g. php81, php80, ... [default: "php81"]
--command[=COMMAND] A command you would like to execute on the site, e.g. php artisan db:seed. (multiple values allowed)
--edit-env[=EDIT-ENV] The colon-separated name and value that will be added/updated in the site's environment, e.g. "MY_API_KEY:my_api_key_value". (multiple values allowed)
--scheduler Setup a cronjob to run Laravel's scheduler.
--no-quick-deploy Create your site without "Quick Deploy".
--no-deploy Avoid deploying the site.
注意:可以多次运行
deploy
命令,并且将跳过之前已运行的任何步骤。
destroy
destroy
命令简单地反转deploy
命令所做的所有操作。它检查Forge中是否存在某些资源,如果存在则删除它们。
该命令接受以下标志
Description:
Destroy a previously created preview site.
Usage:
destroy [options]
Options:
--token[=TOKEN] The Forge API token.
--server[=SERVER] The ID of the target server.
--repo[=REPO] The name of the repository being deployed.
--branch[=BRANCH] The name of the branch being deployed.
--domain[=DOMAIN] The domain you'd like to use for deployments.
由于Forge Previewer基于约定,我们将尝试根据我们为它们生成的名称来检测资源。
示例工作流程
待办事项