使用工作流程部署

了解如何使用 EAS Hosting 和 Workflows 自动化 React Native CI/CD 以进行 Web 部署。


EAS 工作流是一种自动化 React Native CI/CD 管道的好方法,用于将你的项目通过拉取请求 (PR) 预览和生产部署部署到 EAS Hosting 进行 Web 部署。

¥EAS Workflows is a great way to automate the React Native CI/CD pipeline for web deployment of your project to EAS Hosting with pull request (PR) previews and production deployments.

设置工作流程

¥Setup workflows

要使用 EAS 工作流 自动部署你的项目,请按照 开始使用 EAS 工作流 中的说明操作并为你的项目添加 GitHub 集成

¥To use EAS workflows to automatically deploy your project, follow the instructions in Get started with EAS workflows and add the GitHub integration for your project.

创建部署工作流

¥Create a deployment workflow

将以下文件添加到 .eas/workflows/deploy.yml。这将使用生产环境变量,导出 Web 包,部署你的项目,并在你推送到 main 分支时将其提升到生产状态。

¥Add the following file to .eas/workflows/deploy.yml. This will use the production environment variables, export the web bundle, deploy your project and promote it to production whenever you push to the main branch.

.eas/workflows/deploy.yml
name: Deploy

on:
  push:
    branches: ['main']

jobs:
  deploy:
    type: deploy
    name: Deploy
    environment: production
    params:
      prod: true

现在,每当将提交推送到 main 或合并 PR 时,工作流都会运行以部署你的网站。

¥Now, whenever a commit is pushed to main or a PR is merged, the workflow will run to deploy your website.

你还可以通过手动触发来测试此工作流程:

¥You can also test this workflow by triggering it manually:

Terminal
eas workflow:run .eas/workflows/deploy.yml