Firebase 部署
此页面记录了使用 dpl v1 进行的部署,该版本目前是默认版本。下一个主要版本 dpl v2 将很快发布,我们建议您开始使用它。有关详细信息,请参阅 我们的博客文章。您可以在 此处找到 dpl v2 文档。
Travis CI 可以在构建成功后自动将您的应用程序部署到 Firebase。
要使用默认配置,请将您的 Firebase 加密的 令牌 添加到您的 .travis.yml
中,所有其他信息都将从您的 firebase.json
中读取。
deploy:
provider: firebase
token:
secure: "YOUR ENCRYPTED token"
生成您的 Firebase 令牌 #
在 安装 Firebase 工具 后,通过运行以下命令生成您的 Firebase 令牌
# This generates a token, e.g. "1/AD7sdasdasdKJA824OvEFc1c89Xz2ilBlaBlaBla"
firebase login:ci
# Encrypt this token
travis encrypt "1/AD7sdasdasdKJA824OvEFc1c89Xz2ilBlaBlaBla" --add
# This command may generate a warning ("If you tried to pass the name of the repository as the first argument, you probably won't get the results you wanted"). You can ignore it.
当使用 travis encrypt --add
时,您可能会收到 WARNING: The name of the repository is now passed to the command with the -r option
(请参阅 https://github.com/travis-ci/travis-ci/issues/7869)。无论如何,令牌都将添加到您的 .travis.yml
中。如果令牌未添加到其中,请检查并将其移动到 .travis.yml
的 secure:
部分。
请记住,在将其添加到 .travis.yml
之前,要 加密 令牌。
部署到自定义项目 #
要部署到与 firebase.json
中指定的项目不同的项目,请在您的 .travis.yml
中使用 project
键。
deploy:
provider: firebase
token:
secure: "YOUR ENCRYPTED token"
project: "myapp-staging"
向部署添加消息 #
要添加描述部署的消息,请在您的 .travis.yml
中使用 message
键。
deploy:
provider: firebase
token:
secure: "YOUR ENCRYPTED token"
message: "your message"
在部署之前和之后运行命令 #
有时您希望在部署之前或之后运行命令。您可以为此使用 before_deploy
和 after_deploy
阶段。只有在 Travis CI 实际进行部署时,才会触发这些阶段。
before_deploy: "echo 'ready?'"
deploy:
..
after_deploy:
- ./after_deploy_1.sh
- ./after_deploy_2.sh