EAS 工作流中的预打包任务

了解如何在 EAS 工作流中设置和使用预打包的作业。


预封装作业是现成可用的工作流作业,可帮助你自动执行常见任务,例如构建、提交和测试应用。它们提供了一种标准化的方法来处理这些操作,而无需从头编写自定义作业配置。本指南介绍了可用的预封装作业以及如何在工作流中使用它们。

🌐 Pre-packaged jobs are ready-to-use workflow jobs that help you automate common tasks like building, submitting, and testing your app. They provide a standardized way to handle these operations without having to write custom job configurations from scratch. This guide covers the available pre-packaged jobs and how to use them in your workflows.

构建

🌐 Build

将你的项目构建成 Android 或 iOS 应用。

🌐 Build your project into an Android or iOS app.

构建作业可以自定义,以便在构建过程中执行自定义命令。有关更多信息,请参见自定义构建

🌐 Build jobs can be customized so that you can execute custom commands during the build process. See Custom builds for more information.

先决条件

🌐 Prerequisites

要成功使用构建任务,你需要使用 EAS CLI 完成一次构建,并使用与预打包任务相同的平台和配置文件。了解如何创建你的第一个构建以开始使用。

🌐 To successfully use the build job, you'll need to complete a build with EAS CLI using the same platform and profile as the pre-packaged job. Learn how to create your first build to get started.

语法

🌐 Syntax

jobs: build_app: type: build runs_on: string # optional - see https://expo.nodejs.cn/build-reference/infrastructure/ for available options params: platform: android | ios # required profile: string # optional - default: production message: string # optional

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

参数类型描述
platformstring必填。 要构建的平台。可以是 androidios
profilestring可选。要使用的构建配置文件。默认为 production
messagestring可选。附加到构建的自定义信息。在执行 eas build 时对应 --message 标志。

环境变量

🌐 Environment variables

如果在构建过程中需要某些环境变量,你可以将它们包含在你的 eas.json 中,针对你指定的构建 profile。这些变量将从 EAS 环境变量 中获取。

🌐 If you need certain environment variables during the build process, you can include them in your eas.json, for your specified build profile. They will be pulled from EAS environment variables.

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

OutputTypeDescription
build_idstringThe ID of the created build.
app_build_versionstringThe version code/build number of the app.
app_identifierstringThe bundle identifier/package name of the app.
app_versionstringThe version of the app.
channelstringThe update channel used for the build.
distributionstringThe distribution method used. Can be internal or store.
fingerprint_hashstringThe fingerprint hash of the build.
git_commit_hashstringThe git commit hash used for the build.
platformstringThe platform the build was created for. Either android or ios.
profilestringThe build profile used.
runtime_versionstringThe runtime version used.
sdk_versionstringThe SDK version used.
simulatorstringWhether the build is for simulator.

示例

🌐 Examples

以下是一些使用构建作业的实际示例:

🌐 Here are some practical examples of using the build job:

特定平台的基本构建

每当你推送到主分支时,这个工作流程会构建你的 iOS 应用。

🌐 This workflow builds your iOS app whenever you push to the main branch.

.eas/workflows/build-ios.yml
name: Build iOS app on: push: branches: ['main'] jobs: build_ios: name: Build iOS type: build params: platform: ios profile: production
同时为两个平台构建

当你推送到主分支时,此工作流会同时构建 Android 和 iOS 应用。

🌐 This workflow builds both Android and iOS apps in parallel when you push to the main branch.

.eas/workflows/build-all.yml
name: Build for all platforms on: push: branches: ['main'] jobs: build_android: name: Build Android type: build params: platform: android profile: production build_ios: name: Build iOS type: build params: platform: ios profile: production
使用环境变量构建

此工作流程使用自定义环境变量构建你的 Android 应用,这些变量可以在构建过程中使用。

🌐 This workflow builds your Android app with custom environment variables that can be used during the build process.

.eas/workflows/build-with-env.yml
name: Build with environment variables on: push: branches: ['main'] jobs: build_android: name: Build Android type: build env: APP_ENV: production API_URL: https://api.example.com params: platform: android profile: production
使用不同的配置构建

此工作流使用不同的配置创建两个不同的 Android 构建版本——一个用于内部分发,另一个用于通过开发和生产配置进行商店提交。

🌐 This workflow creates two different Android builds using different profiles - one for internal distribution and one for store submission using the development and production profiles.

.eas/workflows/build-profiles.yml
name: Build with different profiles on: push: branches: ['main'] jobs: build_android_development: name: Build Android Development type: build params: platform: android profile: development build_android_production: name: Build Android Production type: build params: platform: android profile: production

部署

🌐 Deploy

使用 EAS Hosting 部署你的应用。

🌐 Deploy your application using EAS Hosting.

先决条件

🌐 Prerequisites

要使用 EAS Hosting 部署你的应用,你需要先设置你的项目。有关更多信息,请参阅 开始使用 EAS Hosting

🌐 To deploy your application using EAS Hosting, you'll need to set up your project. See Get Started with EAS Hosting for more information.

语法

🌐 Syntax

jobs: deploy_web: type: deploy params: alias: string # optional prod: boolean # optional

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

参数类型描述
aliasstring可选。要部署的 别名
prodboolean可选。是否部署到生产环境。

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

OutputTypeDescription
deploy_jsonstringJSON object containing the deployment details (output of npx eas-cli deploy --json).
deploy_urlstringURL to the deployment. It uses production URL if this was a production deployment. Otherwise, it uses the first alias URL or the deployment URL.
deploy_alias_urlstringAlias URL to the deployment (for example, https://account-project--alias.expo.app).
deploy_deployment_urlstringUnique URL to the deployment (for example, https://account-project--uniqueid.expo.app).
deploy_identifierstringIdentifier of the deployment.
deploy_dashboard_urlstringURL to the deployment dashboard (for example, https://expo.dev/projects/[project]/hosting/deployments).

示例

🌐 Examples

以下是一些使用部署任务的实际示例:

🌐 Here are some practical examples of using the deploy job:

基本部署到生产环境

此工作流程使用 EAS Hosting 将你的应用部署到生产环境。

🌐 This workflow deploys your application to production using EAS Hosting.

.eas/workflows/deploy-basic.yml
name: Basic Deployment jobs: deploy: name: Deploy to Production type: deploy params: prod: true
仅在合并到 `main` 分支时部署到生产环境

当你合并到主分支时,此工作流会将你的应用部署到生产环境,并在其他所有分支上进行非生产环境部署。

🌐 This workflow deploys your application to production when you merge to the main branch, and makes a non-production deployment on all other branches.

.eas/workflows/deploy.yml
name: Deploy on: push: branches: ['*'] jobs: deploy: name: Deploy type: deploy params: prod: ${{ github.ref_name == 'main' }}
使用自定义别名的部署

此工作流程将你的应用部署到生产环境中的自定义别名。

🌐 This workflow deploys your application to a custom alias in production.

.eas/workflows/deploy-alias.yml
name: Deployment with Alias jobs: deploy: name: Deploy with Alias type: deploy params: alias: my-custom-alias prod: true

指纹

🌐 Fingerprint

计算项目的指纹。

🌐 Calculates a fingerprint of your project.

注意: 此作业类型仅支持 CNG(托管) 工作流。如果你提交了 androidios 目录,指纹作业将无法运行。

注意: 为确保指纹与你的构建匹配,请使用与构建配置相同的 environment 设置。对于环境变量,我们建议使用 EAS 环境变量,而不是 env 字段,以获得更好的一致性。

语法

🌐 Syntax

jobs: fingerprint: type: fingerprint environment: production | preview | development # optional, defaults to production env: # optional list of environment variables ENV_VAR_NAME: value

环境变量

🌐 Environment variables

你可以将一列环境变量传递给 env 参数。这些环境变量将从 EAS 环境变量 中提取。传递的 environment 参数将用于环境变量的环境,这在相同的环境变量在不同环境中定义时非常有用。

🌐 You can pass a list of environment variables into the env parameter. These environment variables will be pulled from EAS environment variables. The passed environment parameter will be used for the environment variable's environment, which is useful when the same environment variable is defined across different environments.

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

输出类型描述
android_fingerprint_hash字符串Android的指纹哈希
ios_fingerprint_hash字符串iOS的指纹哈希

示例

🌐 Examples

以下是一些使用指纹作业的实际示例:

🌐 Here are some practical examples of using the fingerprint job:

基本指纹计算

此工作流会计算 Android 和 iOS 构建的指纹。environment 应与你的构建配置匹配,以确保指纹匹配准确。

🌐 This workflow calculates fingerprints for both Android and iOS builds. The environment should match your build profile for accurate fingerprint matching.

.eas/workflows/fingerprint-basic.yml
name: Basic Fingerprint jobs: fingerprint: name: Calculate Fingerprint type: fingerprint environment: production
带内联环境变量的指纹

注意: 如果你依赖内联环境变量,你需要确保在每个地方(构建配置文件、指纹任务、更新任务等)都将正确的环境变量设置为正确的值,以使指纹匹配。我们建议使用EAS 环境变量,你可以在其中将一组变量分组到环境中,并在构建配置文件和工作流任务中引用它们。

.eas/workflows/fingerprint-with-env.yml
name: Fingerprint with Environment Variables jobs: fingerprint: name: Calculate Fingerprint type: fingerprint environment: production # Resulting environment will be a union of the "production" environment and the inline environment variables. # `env` variables override environment variables of the same name from the "production" environment. env: APP_VARIANT: staging API_URL: https://api.staging.example.com

获取构建

🌐 Get Build

从 EAS 检索与提供的参数匹配的现有构建。

🌐 Retrieve an existing build from EAS that matches the provided parameters.

语法

🌐 Syntax

jobs: get_build: type: get-build params: platform: ios | android # optional profile: string # optional distribution: store | internal | simulator # optional channel: string # optional app_identifier: string # optional app_build_version: string # optional app_version: string # optional git_commit_hash: string # optional fingerprint_hash: string # optional sdk_version: string # optional runtime_version: string # optional simulator: boolean # optional wait_for_in_progress: boolean # optional

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

ParameterTypeDescription
platformstringOptional. The platform to get the build for. Can be ios or android.
profilestringOptional. The build profile to use.
distributionstringOptional. The distribution method. Can be store, internal, or simulator.
channelstringOptional. The update channel.
app_identifierstringOptional. The bundle identifier/package name.
app_build_versionstringOptional. The build version.
app_versionstringOptional. The app version.
git_commit_hashstringOptional. The git commit hash.
fingerprint_hashstringOptional. The fingerprint hash.
sdk_versionstringOptional. The SDK version.
runtime_versionstringOptional. The runtime version.
simulatorbooleanOptional. Whether to get a simulator build.
wait_for_in_progressbooleanOptional. Whether to wait for a matching in-progress build. Default: false.

如果将 wait_for_in_progress 设置为 true,作业仍会优先立即继续使用已成功的构建,但它也会查找正在进行中的构建。如果未找到成功的构建,作业将等待正在进行的构建完成后再继续。如果匹配的构建成功,作业将被标记为成功,并返回该成功的构建。如果匹配的构建失败,作业仍将被标记为成功,其输出将为空——就好像该构建未被匹配一样。

🌐 If wait_for_in_progress is set to true, the job will still prioritize continuing immediately with a successful build, but it will also look for in-progress builds. If no successful build is found, the job will wait for an in-progress build to complete before continuing. If the matched build succeeds, the job will be marked as successful and will return the successful build. If the matched build fails, the job will be marked as successful and its outputs will be empty — as if the build has not been matched.

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

OutputTypeDescription
build_idstringThe ID of the retrieved build.
app_build_versionstringThe build version of the app.
app_identifierstringThe bundle identifier/package name of the app.
app_versionstringThe version of the app.
channelstringThe update channel used for the build.
distributionstringThe distribution method used.
fingerprint_hashstringThe fingerprint hash of the build.
git_commit_hashstringThe git commit hash used for the build.
platformstringThe platform the build was created for.
profilestringThe build profile used.
runtime_versionstringThe runtime version used.
sdk_versionstringThe SDK version used.
simulatorstringWhether the build is for simulator.

示例

🌐 Examples

以下是使用 get-build 任务的一些实际示例:

🌐 Here are some practical examples of using the get-build job:

获取最新的生产版本

此工作流从商店分发渠道获取最新的 iOS 生产版本。

🌐 This workflow retrieves the latest production build for iOS from the store distribution channel.

.eas/workflows/get-build-production.yml
name: Get Production Build jobs: get_build: name: Get Latest Production Build type: get-build params: platform: ios profile: production distribution: store channel: production
按版本构建

此工作流程通过应用版本和构建版本检索特定版本的 Android 构建。

🌐 This workflow retrieves a specific version of an Android build by its app version and build version.

.eas/workflows/get-build-version.yml
name: Get Build by Version jobs: get_build: name: Get Specific Version Build type: get-build params: platform: android app_identifier: com.example.app app_version: 1.0.0 app_build_version: 42
获取模拟器构建

此工作流程用于获取 iOS 开发的模拟器构建。wait_for_in_progress 设置为 true,以便如果已经存在匹配过滤器的构建,作业将在其完成之前等待。

🌐 This workflow retrieves a simulator build for iOS development. wait_for_in_progress is set to true so that if a build matching the filter already exists, the job will wait for it to complete before continuing.

.eas/workflows/get-build-simulator.yml
name: Get Simulator Build jobs: get_build: name: Get Simulator Build type: get-build params: platform: ios simulator: true profile: development wait_for_in_progress: true

提交

🌐 Submit

使用 EAS Submit 将 Android 或 iOS 版本提交到应用商店。

🌐 Submit an Android or iOS build to the app store using EAS Submit.

先决条件

🌐 Prerequisites

提交任务需要额外配置才能在 CI/CD 流程中运行。有关更多信息,请参阅我们的 苹果应用商店 CI/CD 提交指南谷歌 Play 商店 CI/CD 提交指南

🌐 Submission jobs require additional configuration to run within a CI/CD process. See our Apple App Store CI/CD submission guide and Google Play Store CI/CD submission guide for more information.

语法

🌐 Syntax

jobs: submit_to_store: type: submit runs_on: string # optional - see https://expo.nodejs.cn/build-reference/infrastructure/ for available options params: build_id: string # required profile: string # optional - default: production

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

参数类型描述
build_id字符串必填。要提交的构建 ID。
profile字符串可选。要使用的提交配置文件。默认值为 production

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

输出类型描述
apple_app_id字符串提交构建的苹果应用 ID
ios_bundle_identifier字符串提交构建的 iOS 包标识符
android_package_id字符串提交构建的 Android 包 ID

示例

🌐 Examples

以下是一些使用提交作业的实际示例:

🌐 Here are some practical examples of using the submit job:

提交 iOS 构建

此工作流程使用生产提交配置将 iOS 构建提交到 App Store。

🌐 This workflow submits an iOS build to the App Store using the production submit profile.

.eas/workflows/submit-ios.yml
name: Submit iOS Build jobs: build_ios: name: Build iOS type: build params: platform: ios profile: production submit: name: Submit to App Store type: submit needs: [build_ios] params: build_id: ${{ needs.build_ios.outputs.build_id }} profile: production
提交 Android 构建

此工作流程使用生产提交配置将 Android 构建提交到 Play 商店。

🌐 This workflow submits an Android build to the Play Store using the production submit profile.

.eas/workflows/submit-android.yml
name: Submit Android Build jobs: build_android: name: Build Android type: build params: platform: android profile: production submit: name: Submit to Play Store type: submit needs: [build_android] params: build_id: ${{ needs.build_android.outputs.build_id }} profile: production

TestFlight

将 iOS 构建分发到 TestFlight 的内部和外部测试组。这是 iOS 提交作业的替代方案,当你需要更高级的 TestFlight 功能时使用。如果你需要控制测试组、更新日志或测试版应用审核提交,请使用 testflight 作业而不是提交。

🌐 Distribute iOS builds to TestFlight internal and external testing groups. This is an alternative to the iOS submit job for when you need more advanced TestFlight features. If you need to control test groups, changelog, or Beta App Review submission, use the testflight job instead of submit.

先决条件

🌐 Prerequisites

TestFlight 任务需要使用 distribution: store 创建的 iOS 构建。你需要配置好你的 Apple 开发者账户。有关更多信息,请参阅 TestFlight 提交指南

🌐 TestFlight jobs require an iOS build created with distribution: store. You'll need to have your Apple Developer account configured. See the TestFlight submission guide for more information.

语法

🌐 Syntax

jobs: testflight_distribution: type: testflight runs_on: string # optional - see https://expo.nodejs.cn/build-reference/infrastructure/ for available options params: build_id: string # required profile: string # optional - default: production internal_groups: string[] # optional external_groups: string[] # optional changelog: string # optional submit_beta_review: boolean # optional wait_processing_timeout_seconds: number # optional - default: 1800 (30 minutes)

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

ParameterTypeDescription
build_idstringRequired. The ID of the iOS build to distribute.
profilestringOptional. The submit profile to use. Defaults to production.
internal_groupsstring[]Optional. An array of TestFlight internal group names to add the build to. Only include groups without automatic distribution enabled.
external_groupsstring[]Optional. An array of TestFlight external group names to add the build to.
changelogstringOptional. Test notes ("What to Test") for TestFlight testers.
submit_beta_reviewbooleanOptional. Whether to submit for Beta App Review. If not specified, defaults to true when external_groups are provided, false otherwise.
wait_processing_timeout_secondsnumberOptional. Timeout in seconds to wait for App Store Connect build processing. Defaults to 1800 (30 minutes).

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

输出类型描述
apple_app_id字符串提交版本的 Apple 应用 ID。
ios_bundle_identifier字符串提交版本的 iOS 应用包标识符。

示例

🌐 Examples

以下是一些使用 TestFlight 任务的实际示例:

🌐 Here are some practical examples of using the TestFlight job:

向内部和外部群体的完整分发

此工作流程会将更新分发到内部和外部 TestFlight 群组,并附带更新日志。

🌐 This workflow distributes to both internal and external TestFlight groups with a changelog.

.eas/workflows/testflight-full.yml
name: TestFlight Distribution jobs: build_ios: name: Build iOS type: build params: platform: ios profile: production testflight: name: Distribute to TestFlight type: testflight needs: [build_ios] params: build_id: ${{ needs.build_ios.outputs.build_id }} internal_groups: ['QA Team'] external_groups: ['Public Beta'] changelog: | What's new in this release: - New features - Bug fixes
仅上传更新日志

这个工作流程会上传一个带有更改日志的构建,但不会指定任何明确要添加构建的组。该构建只会被添加到启用了“自动分发”的内部组中。

🌐 This workflow uploads a build with a changelog but without specifying any groups to explicitly add the build to. The build will only get added to internal groups with "auto-distribute" enabled.

.eas/workflows/testflight-changelog.yml
name: TestFlight with Changelog jobs: testflight: name: Upload with Changelog type: testflight params: build_id: ${{ needs.build_ios.outputs.build_id }} changelog: "${{ github.commit_message || 'Bug fixes' }}" # github.commit_message only available in push & schedule events.

更新

🌐 Update

使用 EAS Update 发布更新。

🌐 Publish an update using EAS Update.

先决条件

🌐 Prerequisites

要发布更新预览并发送空中更新,你需要先运行 npx eas-cli@latest update:configure,然后创建新的构建版本。了解有关配置 EAS 更新的更多信息。

🌐 To publish update previews and to send over-the-air updates, you'll need to run npx eas-cli@latest update:configure, then create new builds. Learn more about configuring EAS Update.

语法

🌐 Syntax

jobs: publish_update: type: update environment: production | preview | development # optional, defaults to production env: # optional list of environment variables ENV_VAR_NAME: value runs_on: string # optional - see https://expo.nodejs.cn/build-reference/infrastructure/ for available options params: message: string # optional platform: string # optional - android | ios | all, defaults to all branch: string # optional channel: string # optional - cannot be used with branch private_key_path: string # optional upload_sentry_sourcemaps: boolean # optional - defaults to "try uploading, but don't fail the job if it fails"

环境变量

🌐 Environment variables

你可以将一列环境变量传递给 env 参数。这些环境变量将从 EAS 环境变量 中提取。传递的 environment 参数将用于环境变量的环境,这在相同的环境变量在不同环境中定义时非常有用。

🌐 You can pass a list of environment variables into the env parameter. These environment variables will be pulled from EAS environment variables. The passed environment parameter will be used for the environment variable's environment, which is useful when the same environment variable is defined across different environments.

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

ParameterTypeDescription
messagestringOptional. Message to use for the update. If not provided, the commit message will be used.
platformstringOptional. Platform to use for the update. Can be android, ios, or all. Defaults to all.
branchstringOptional. Branch to use for the update. If not provided, the branch from the workflow run will be used. For manually run workflows you need to provide a value. Example: ${{ github.ref_name || 'testing' }}. Provide either a branch or a channel, not both.
channelstringOptional. Channel to use for the update. Provide either a branch or a channel, not both.
private_key_pathstringOptional. Path to the file containing the PEM-encoded private key corresponding to the certificate in EAS Update configuration. You can reference a file type EAS environment variable with "$VARIABLE_NAME" syntax. This is equivalent to passing --private-key-path to the EAS CLI.
upload_sentry_sourcemapsbooleanOptional. Whether to upload Sentry sourcemaps. If the value is true, the job will upload Sentry source maps and fail if uploading fails. If the value is false, the job will not upload sourcemaps to Sentry. If the value is not provided, the job is going to check if @sentry/react-native is installed and if it is, try to upload sourcemaps. If that fails, it will only print the error message and continue with the job marked as successful.

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

输出类型描述
first_update_group_id字符串第一个更新组的ID。
updates_json字符串包含所有更新组信息的JSON字符串。

示例

🌐 Examples

以下是一些使用更新作业的实际示例:

🌐 Here are some practical examples of using the update job:

对生产通道的基本更新

每当你向主分支推送时,此工作流会将更新发布到生产渠道,并使用提交信息作为更新信息。

🌐 This workflow publishes an update to the production channel whenever you push to the main branch, using the commit message as the update message.

.eas/workflows/update-production.yml
name: Update Production on: push: branches: ['main'] jobs: update_production: name: Update Production Channel type: update params: channel: production
特定平台的更新

此工作流程为 Android 和 iOS 平台发布单独的更新,允许进行特定于平台的更改。

🌐 This workflow publishes separate updates for Android and iOS platforms, allowing for platform-specific changes.

.eas/workflows/update-platforms.yml
name: Platform-specific Updates on: push: branches: ['main'] jobs: update_android: name: Update Android type: update params: platform: android channel: production update_ios: name: Update iOS type: update params: platform: ios channel: production
使用基于分支的部署进行更新

此工作流程会根据分支名称发布更新,从而根据分支区分不同的环境(测试/生产)。

🌐 This workflow publishes updates based on the branch name, allowing for different environments (staging/production) based on the branch.

.eas/workflows/update-branches.yml
name: Branch-based Updates on: push: branches: ['main', 'staging'] jobs: update_branch: name: Update Branch type: update params: branch: ${{ github.ref_name }} message: 'Update for branch: ${{ github.ref_name }}'

大师

🌐 Maestro

在 Android 模拟器或 iOS 模拟器构建上运行 Maestro 测试。

🌐 Run Maestro tests on a Android emulator or iOS Simulator build.

重要 Maestro 测试处于 alpha 阶段。

语法

🌐 Syntax

jobs: run_maestro_tests: type: maestro environment: production | preview | development # optional - defaults to preview image: string # optional - see https://expo.nodejs.cn/build-reference/infrastructure/ for a list of available images. params: build_id: string # required flow_path: string | string[] # required shards: number # optional - defaults to 1 retries: number # optional - defaults to 1 record_screen: boolean # optional - defaults to false include_tags: string | string[] # optional exclude_tags: string | string[] # optional maestro_version: string # optional - defaults to latest android_system_image_package: string # optional device_identifier: string | { android: string, ios: string } # optional

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

ParameterTypeDescription
build_idstringRequired. The ID of the build to test.
flow_pathstring or string[]Required. The path to the Maestro flow file(s) or directory to run.
shardsnumberOptional and experimental. The number of shards to split the tests into. Defaults to 1.
retriesnumberOptional. The number of times to retry failed tests. Defaults to 1.
record_screenbooleanOptional. Whether to record the screen. Defaults to false. Note: recording screen may impact emulator performance. You may want to use large runners when recording screen.
include_tagsstring or string[]Optional. Flow tags to include in the tests. Will be passed to Maestro as --include-tags.
exclude_tagsstring or string[]Optional. Flow tags to exclude from the tests. Will be passed to Maestro as --exclude-tags.
maestro_versionstringOptional. Version of Maestro to use for the tests. If not provided, the latest version will be used.
output_formatstringOptional. Maestro test report format. Will be passed to Maestro as --format. Can be junit or other supported formats.
android_system_image_packagestringOptional. Android Emulator system image package to use. Run sdkmanager --list on your machine to list available packages. Choose an x86_64 variant. Examples: system-images;android-36;google_apis;x86_64, system-images;android-35-ext15;google_apis_playstore;x86_64. Note that newer images require more computing resources, for which you may want to use large runners.
device_identifierstring or { android?: string, ios?: string } objectOptional. Device identifier to use for the tests. You can also use a single-value expression like pixel_6, iPhone 16 Plus or ${{ needs.build.outputs.platform == "android" ? "pixel_6" : "iPhone 16 Plus" }} and an object like device_identifier: { android: "pixel_6", ios: "iPhone 16 Plus" }. Note that iOS devices availability differs across runner images. A list of available devices can be found in the jobs logs.
skip_build_checkbooleanOptional. Skip validation of the build (whether an iOS build is a simulator build). Defaults to false.

示例

🌐 Examples

以下是一些使用 Maestro 任务的实际示例:

🌐 Here are some practical examples of using the Maestro job:

基础大师测试

此工作流使用默认设置在 iOS 模拟器构建上运行 Maestro 测试。

🌐 This workflow runs Maestro tests on an iOS Simulator build using the default settings.

.eas/workflows/maestro-basic.yml
name: Basic Maestro Test jobs: test: name: Run Maestro Tests type: maestro environment: preview params: build_id: ${{ needs.build_ios_simulator.outputs.build_id }} flow_path: ./maestro/flows
Maestro 分片测试

此工作流在 Android 模拟器上运行 Maestro 测试,使用 3 个分片,并对失败的测试进行 2 次重试。

🌐 This workflow runs Maestro tests on an Android emulator build with 3 shards and 2 retries for failed tests.

.eas/workflows/maestro-sharded.yml
name: Sharded Maestro Test jobs: test: name: Run Sharded Maestro Tests type: maestro environment: preview runs_on: linux-large-nested-virtualization params: build_id: ${{ needs.build_android_emulator.outputs.build_id }} flow_path: ./maestro/flows shards: 3 retries: 2
使用 Maestro 前缀的环境变量

当变量以 MAESTRO_ 为前缀时,Maestro 可以在工作流中自动读取环境变量。更多信息,请参见 Maestro 关于 shell 变量的文档

🌐 Maestro can automatically read environment variables in a workflow when the variable is prefixed by MAESTRO_. For more information, see the Maestro documentation on shell variables.

.eas/workflows/maestro-basic.yml
name: Basic Maestro Test jobs: test: name: Run Maestro Tests type: maestro env: MAESTRO_APP_ID: 'com.yourhost.yourapp' params: build_id: ${{ needs.build_ios_simulator.outputs.build_id }}
录制屏幕并使用特定设备

此工作流程在使用特定设备构建的 Android 模拟器上运行 Maestro 测试并录制屏幕。

🌐 This workflow runs Maestro tests on an Android emulator build with a specific device and records the screen.

.eas/workflows/maestro-sharded.yml
name: Pixel E2E Test jobs: test: name: Run Maestro Tests type: maestro runs_on: linux-large-nested-virtualization params: build_id: ${{ needs.build_android_emulator.outputs.build_id }} device_identifier: 'pixel_6' record_screen: true android_system_image_package: 'system-images;android-35;default;x86_64'
保存截图和录制

要保存由 Maestro 命令(例如 takeScreenshotstartRecording)创建的资源以便后续调试使用,请使用 MAESTRO_TESTS_DIR 环境变量。

🌐 To save assets created by Maestro commands (such as takeScreenshot or startRecording) to use for debugging later, use the MAESTRO_TESTS_DIR environment variable.

在你的 Maestro 流程文件中,指定资源位置:

🌐 In your Maestro flow file, specify the asset locations:

maestro/flows/test-flow.yaml
appId: com.myapp --- - launchApp - startRecording: ${MAESTRO_TESTS_DIR}/my_recording - takeScreenshot: ${MAESTRO_TESTS_DIR}/my_screenshot - tapOn: 'Login Button' - takeScreenshot: ${MAESTRO_TESTS_DIR}/after_login_screenshot - stopRecording

这些资源将可以在“Maestro 测试结果”工件的工件部分中获取。

🌐 The assets will be available within the "Maestro Test Results" artifact in the Artifacts section.

Maestro 云

🌐 Maestro Cloud

在 Maestro Cloud 上运行 Maestro 测试。

🌐 Run Maestro tests on Maestro Cloud.

重要 这需要一个 Maestro Cloud 账户和 Cloud 订阅计划。请访问 Maestro 文档 了解更多信息。

语法

🌐 Syntax

jobs: run_maestro_tests: type: maestro-cloud environment: production | preview | development # optional - defaults to preview image: string # optional- see https://expo.nodejs.cn/build-reference/infrastructure/ for a list of available images. params: build_id: string # required - ID of the build to test. maestro_project_id: string # required - Maestro Cloud project ID. Example: `proj_01jw6hxgmdffrbye9fqn0pyzm0`. flows: string # required - Path to the Maestro flow file or directory containing the flows to run. Corresponds to `--flows` param to `maestro cloud`. maestro_api_key: string # optional - defaults to `$MAESTRO_CLOUD_API_KEY` include_tags: string | string[] # optional - tags to include in the tests. Will be passed to Maestro as `--include-tags`. exclude_tags: string | string[] # optional - tags to exclude from the tests. Will be passed to Maestro as `--exclude-tags`. maestro_version: string # optional - version of Maestro to use for the tests. If not provided, the latest version will be used. android_api_level: string # optional - Android API level to use for the tests. Will be passed to Maestro as `--android-api-level`. maestro_config: string # optional - path to the Maestro `config.yaml` file to use for the tests. Will be passed to Maestro as `--config`. device_locale: string # optional - device locale to use for the tests. Will be passed to Maestro as `--device-locale`. Run `maestro cloud --help` for a list of supported values. device_model: string # optional - model of the device to use for the tests. Will be passed to Maestro as `--device-model`. Run `maestro cloud --help` for a list of supported values. device_os: string # optional - OS of the device to use for the tests. Will be passed to Maestro as `--device-os`. Run `maestro cloud --help` for a list of supported values. name: string # optional - name for the Maestro Cloud upload. Corresponds to `--name` param to `maestro cloud`. branch: string # optional - override for the branch the Maestro Cloud upload originated from. By default, if the workflow run has been triggered from GitHub, the branch of the workflow run will be used. Corresponds to `--branch` param to `maestro cloud`. async: boolean # optional - run the Maestro Cloud tests asynchronously. If true, the status of the job will only denote whether the upload was successful, _not_ whether the tests succeeded. Corresponds to `--async` param to `maestro cloud`.

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

ParameterTypeDescription
build_idstringRequired. The ID of the build to test. Example: ${{ needs.build_android.outputs.build_id }}.
maestro_project_idstringRequired. The ID of the Maestro Cloud project to use. Corresponds to --project-id param to maestro cloud. Example: proj_01jw6hxgmdffrbye9fqn0pyzm0. Go to Maestro Cloud to find yours.
flowsstringRequired. The path to the Maestro flow file or directory containing the flows to run. Corresponds to --flows param to maestro cloud.
maestro_api_keystringOptional. The API key to use for the Maestro project. By default, MAESTRO_CLOUD_API_KEY environment variable will be used. Corresponds to --api-key param to maestro cloud.
include_tagsstringOptional. The tags to include in the tests. Corresponds to --include-tags param to maestro cloud. Example: "pull,push".
exclude_tagsstringOptional. The tags to exclude from the tests. Corresponds to --exclude-tags param to maestro cloud. Example: "disabled".
maestro_versionstringOptional. The version of Maestro to use. Example: 1.30.0.
android_api_levelstringOptional. The Android API level to use. Corresponds to --android-api-level param to maestro cloud. Example: 29.
maestro_configstringOptional. The path to the Maestro config.yaml file to use. Corresponds to --config param to maestro cloud. Example: .maestro/config.yaml.
device_localestringOptional. The locale that will be set on devices used for the tests. Corresponds to --device-locale param to maestro cloud. Example: pl_PL.
device_modelstringOptional. The model of the device to use for the tests. Corresponds to --device-model param to maestro cloud. Example: iPhone-11. Run maestro cloud --help for a list of supported values.
device_osstringOptional. The OS of the device to use for the tests. Corresponds to --device-os param to maestro cloud. Example: iOS-18-2. Run maestro cloud --help for a list of supported values.
namestringOptional. Name for the Maestro Cloud upload. Corresponds to --name param to maestro cloud.
branchstringOptional. Override for the branch the Maestro Cloud upload originated from. By default, if the workflow run has been triggered from GitHub, the branch of the workflow run will be used. Corresponds to --branch param to maestro cloud.
asyncbooleanOptional. Run the Maestro Cloud tests asynchronously. If true, the status of the job will only denote whether the upload was successful, not whether the tests succeeded. Corresponds to --async param to maestro cloud.

重要 你需要在作业环境中设置 maestro_api_key 参数或 MAESTRO_CLOUD_API_KEY 环境变量。请访问 Maestro Cloud 的“设置”来生成 API 密钥,然后到 环境变量 将其添加到你的项目中。

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

输出类型描述
maestro_cloud_url字符串Maestro Cloud上传结果页面的URL。
total_flows_count数字执行的流的总数。
successful_flows_count数字成功完成的流的数量(状态为SUCCESS或WARNING)。
failed_flows_count数字失败的流的数量(状态为ERROR或STOPPED)。
successful_flow_names_json字符串包含成功流名称的JSON数组。
failed_flow_names_json字符串包含失败流名称的JSON数组。

注意: 使用 async: true 模式时,只有 maestro_cloud_url 输出可以保证有效。其他输出(流程计数和流程名称)可能无效或为空,因为任务不会等待上传完成,并且流程尚未执行。

示例

🌐 Examples

以下是一些使用 Maestro 任务的实际示例:

🌐 Here are some practical examples of using the Maestro job:

基础 Maestro 云测试

此工作流使用默认设置在 iOS 模拟器构建上运行 Maestro 测试。

🌐 This workflow runs Maestro tests on an iOS Simulator build using the default settings.

.eas/workflows/maestro-basic.yml
name: Basic Maestro Test jobs: test: name: Run Maestro Tests type: maestro-cloud environment: preview params: build_id: ${{ needs.build_ios_simulator.outputs.build_id }} maestro_project_id: proj_01jw6hxgmdffrbye9fqn0pyzm0 flows: ./maestro/flows
使用 Maestro 前缀的环境变量

当变量以 MAESTRO_ 为前缀时,Maestro 可以在工作流中自动读取环境变量。更多信息,请参见 Maestro 关于 shell 变量的文档

🌐 Maestro can automatically read environment variables in a workflow when the variable is prefixed by MAESTRO_. For more information, see the Maestro documentation on shell variables.

.eas/workflows/maestro-basic.yml
name: Basic Maestro Test jobs: test: name: Run Maestro Tests type: maestro-cloud env: MAESTRO_APP_ID: 'com.yourhost.yourapp' params: build_id: ${{ needs.build_ios_simulator.outputs.build_id }} maestro_project_id: proj_01jw6hxgmdffrbye9fqn0pyzm0 flows: ./maestro/flows
在后续作业中使用 Maestro Cloud 输出

此工作流运行 Maestro Cloud 测试,然后在 Slack 通知中使用测试结果。

🌐 This workflow runs Maestro Cloud tests and then uses the test results in a Slack notification.

.eas/workflows/maestro-with-notification.yml
name: Maestro Cloud with Notification jobs: maestro_test: name: Run Maestro Cloud Tests type: maestro-cloud environment: preview params: build_id: ${{ needs.build.outputs.build_id }} maestro_project_id: proj_xyz flows: ./maestro/flows notify: name: Send Test Results after: [maestro_test] type: slack environment: production params: webhook_url: ${{ env.SLACK_WEBHOOK_URL }} # make sure to set it up in the right environment (see "environment: ..." above) message: 'Tests complete: ${{ after.maestro_test.outputs.successful_flows_count }}/${{ after.maestro_test.outputs.total_flows_count }} passed'

Slack

使用 Slack webhook URL 向 Slack 通道发送消息。

🌐 Send a message to a Slack channel using a Slack webhook URL.

语法

🌐 Syntax

jobs: send_slack_notification: type: slack params: webhook_url: string # required message: string # required if payload is not provided payload: object # required if message is not provided

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

参数类型描述
webhook_urlstring必填。用于发送消息的 Slack webhook URL。目前仅支持硬编码字符串。使用存储在 env 中的 webhook 功能即将推出,但尚不支持。
messagestring如果未提供 payload,则此项为必填。要发送的消息内容。
payloadobject如果未提供 message,则此项为必填。要发送的 Slack Block Kit payload。

示例

🌐 Examples

以下是一些使用 Slack 职位的实际示例:

🌐 Here are some practical examples of using the Slack job:

基本构建通知

该工作流程会构建一个 iOS 应用,然后发送一条通知,内容包括构建任务输出的应用标识符和版本。

🌐 This workflow builds an iOS app and then sends a notification with the app identifier and version from the build job outputs.

.eas/workflows/slack-build-notification.yml
name: Build Notification jobs: build_ios: name: Build iOS type: build params: platform: ios profile: production notify_build: name: Notify Build Status needs: [build_ios] type: slack params: webhook_url: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX message: 'Build completed for app ${{ needs.build_ios.outputs.app_identifier }} (version ${{ needs.build_ios.outputs.app_version }})'
使用 Block Kit 的丰富构建通知

此工作流构建一个 Android 应用,并使用构建作业的输出发送富通知。

🌐 This workflow builds an Android app and sends a rich notification using the build job outputs.

.eas/workflows/slack-rich-notification.yml
name: Rich Build Notification jobs: build_android: name: Build Android type: build params: platform: android profile: production notify_build: name: Notify Build Status needs: [build_android] type: slack params: webhook_url: https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX payload: blocks: - type: header text: type: plain_text text: 'Build Completed' - type: section fields: - type: mrkdwn text: "*App:*\n${{ needs.build_android.outputs.app_identifier }}" - type: mrkdwn text: "*Version:*\n${{ needs.build_android.outputs.app_version }}" - type: section fields: - type: mrkdwn text: "*Build ID:*\n${{ needs.build_android.outputs.build_id }}" - type: mrkdwn text: "*Platform:*\n${{ needs.build_android.outputs.platform }}" - type: section text: type: mrkdwn text: 'Distribution: ${{ needs.build_android.outputs.distribution }}'

GitHub 评论

🌐 GitHub Comment

自动将工作流已完成的构建、更新和部署报告发布到 GitHub 拉取请求中。它特别适用于对 PR 构建提供即时反馈、通过二维码分享测试构建以便轻松在设备上测试、显示 EAS Hosting 部署预览以及自动化部署通知。你还可以通过提供 payload 参数来覆盖评论内容。

🌐 Automatically post reports of your workflow's completed builds, updates, and deployments to GitHub pull requests. It's particularly useful for providing instant feedback on PR builds, sharing test builds with QR codes for easy device testing, displaying EAS Hosting deployment previews, and automating deployment notifications. You can also override the comment contents by providing the payload parameter.

先决条件

🌐 Prerequisites

要使用 GitHub 评论任务,你的项目必须连接到 GitHub 仓库。了解如何连接你的 GitHub 仓库以开始使用。

🌐 To use the GitHub Comment job, your project must have a GitHub repository connected. Learn how to connect your GitHub repository to get started.

语法

🌐 Syntax

jobs: github_comment: type: github-comment params: message: string # optional - custom message to include in the report build_ids: string[] # optional - specific build IDs to include, defaults to all related to the running workflow update_group_ids: string[] # optional - specific update group IDs to include, defaults to all related to the workflow deployment_ids: string[] # optional - specific deployment IDs to include, defaults to all related to the workflow # instead of using message and the builds, updates, and deployments table, you can also override the comment contents with `payload` custom_github_comment: type: github-comment params: payload: string # optional - raw markdown/HTML content for fully custom comment

参数

🌐 Parameters

该工作以两种互斥的模式运行:

🌐 The job operates in two mutually exclusive modes:

模式1:自动模式(可覆盖)

🌐 Mode 1: Auto-with-overrides mode

默认行为是自动发现构建和更新,如果需要,你可以指定以下任意参数:

🌐 Default behavior is auto discovery builds and updates, you can specify any of these parameters if you want to:

ParameterTypeDescription
messagestringOptional. Custom message to include at the top of the comment. Defaults to "Your builds, updates, and deployments are ready for testing!"
build_idsstring[]Optional. Array of specific build IDs to include. If not specified, auto-discovers all completed/failed/canceled builds. Use empty array [] to exclude builds.
update_group_idsstring[]Optional. Array of specific update group IDs to include. If not specified, auto-discovers all successful updates. Use empty array [] to exclude updates.
deployment_idsstring[]Optional. Array of specific deployment IDs to include. If not specified, auto-discovers all successful deployments. Use empty array [] to exclude deployments.

自动发现行为:当未指定(未定义)build_idsupdate_group_idsdeployment_ids 时,作业会自动从当前工作流中发现所有相关的构建、更新和部署。要明确排除构建、更新或部署,请传递一个空数组 []

模式 2:有效载荷模式

🌐 Mode 2: Payload mode

使用有效载荷模式时,你不能指定任何其他参数。

🌐 When using payload mode, you cannot specify any other parameters.

参数类型描述
payload字符串要作为评论发布的原始 Markdown 或 HTML 内容。支持工作流变量插值。

输出

🌐 Outputs

你可以在后续作业中引用以下输出:

🌐 You can reference the following outputs in subsequent jobs:

输出类型描述
comment_url字符串已发布 GitHub 评论的 URL(仅在评论成功发布时可用)。

示例

🌐 Examples

以下是展示 GitHub 评论作业两种模式的实际示例:

🌐 Here are practical examples demonstrating both modes of the GitHub Comment job:

自动覆盖模式示例

🌐 Auto-with-overrides mode examples

自动发现所有构建、更新和部署

这是最简单的用法——自动发现并发布工作流程中的所有构建、更新和部署。

🌐 This is the simplest usage - automatically discovers and posts all builds, updates, and deployments from the workflow.

.eas/workflows/pr-auto-comment.yml
name: PR Auto Comment on: pull_request: {} jobs: # ... comment_on_pr: name: Post Results to PR after: [build_ios, build_android, publish_update, deploy] type: github-comment # No params needed - auto-discovers all builds, updates, and deployments
带自动发现的自定义消息

在仍然自动发现所有构建、更新和部署的同时添加自定义消息。

🌐 Adds a custom message while still auto-discovering all builds, updates, and deployments.

.eas/workflows/pr-custom-message.yml
name: PR Custom Message on: pull_request: {} jobs: # ... comment_on_pr: name: Post Build to PR after: [build_ios, build_android, publish_update, deploy] type: github-comment params: message: '🎉 Preview builds are ready! Please test these changes before approving the PR.' # build_ids, update_group_ids, and deployment_ids are undefined, so auto-discovery is enabled
带有 EAS 托管部署的 PR 预览

此工作流使用 EAS 托管部署你网站的预览版本,并将部署详情发布到拉取请求中。

🌐 This workflow deploys a preview of your website using EAS Hosting and posts the deployment details to the pull request.

.eas/workflows/pr-preview.yml
name: PR Preview on: pull_request: {} jobs: deploy: type: deploy name: Deploy PR Preview comment: needs: [deploy] type: github-comment
指定确切的版本和更新

在评论中明确指定要包含的构建和更新。

🌐 Explicitly specify which builds and updates to include in the comment.

.eas/workflows/pr-specific-builds.yml
name: PR Specific Builds on: pull_request: {} jobs: # ... comment_update: name: Post Update to PR after: [build_ios, build_android, publish_update] type: github-comment params: message: 'Testing builds ready for QA review' build_ids: - ${{ after.build_ios.outputs.build_id }} - ${{ after.build_android.outputs.build_id }} update_group_ids: - ${{ after.publish_update.outputs.first_update_group_id }}
排除构建、更新或部署

使用空数组来排除特定的内容类型。

🌐 Use empty arrays to exclude specific content types.

.eas/workflows/pr-updates-only.yml
name: PR Updates Only on: pull_request: {} jobs: # ... comment_updates_only: name: Post Updates Only after: [publish_update] type: github-comment params: message: 'New update available for testing!' build_ids: [] # Empty array excludes all builds deployment_ids: [] # Empty array excludes all deployments # update_group_ids undefined = auto-discover updates

有效载荷模式示例

🌐 Payload mode examples

带有效载荷的完全自定义评论

有效载荷模式让你可以完全控制评论内容。请注意,当使用有效载荷时,你不能指定任何其他参数。

🌐 Payload mode gives you complete control over the comment content. Note that when using payload, you cannot specify any other parameters.

.eas/workflows/custom-pr-comment.yml
name: Custom PR Comment on: pull_request: {} jobs: # ... custom_comment: name: Post Custom Comment needs: [build_ios] type: github-comment params: # Payload mode: complete control over content # Cannot use message, build_ids, or update_group_ids with payload payload: | ## 🚀 Build Status Update ### iOS Build Completed - **Build ID**: `${{ needs.build_ios.outputs.build_id }}` - **Version**: ${{ needs.build_ios.outputs.app_version }} - **Build Number**: ${{ needs.build_ios.outputs.app_build_version }} ### Next Steps 1. Download the build from [EAS Dashboard](https://expo.dev/accounts/[account]/projects/[project]/builds/${{ needs.build_ios.outputs.build_id }}) 2. Test on physical device 3. Approve for TestFlight distribution --- *This comment was automatically generated by EAS Workflows*
基于构建状态的条件注释

该工作流程会根据构建是成功还是失败发布不同的评论。

🌐 This workflow posts different comments based on whether the build succeeded or failed.

.eas/workflows/conditional-comment.yml
name: Conditional PR Comment on: pull_request: {} jobs: build_android: name: Build Android type: build params: platform: android profile: preview comment_success: name: Post Success Comment needs: [build_android] if: ${{ needs.build_android.status == 'success' }} type: github-comment params: message: '✅ Android build succeeded! Ready for testing.' build_ids: # provided only for instructional purposes, you could as well omit this here - ${{ needs.build_android.outputs.build_id }} comment_failure: name: Post Failure Comment after: [build_android] if: ${{ after.build_android.status == 'failure' }} type: github-comment params: payload: | ❌ **Android build failed** Please check the [workflow logs](https://expo.dev/accounts/[account]/projects/[project]/workflows) for details.

需要批准

🌐 Require Approval

在继续工作流程之前,需要用户的批准。用户可以批准或拒绝,这将对应任务的成功或失败。

🌐 Require approval from a user before continuing with the workflow. A user can approve or reject which translates to success or failure of the job.

语法

🌐 Syntax

jobs: require_approval: type: require-approval

参数

🌐 Parameters

这个任务不需要任何参数。

🌐 This job doesn't take any parameters.

示例

🌐 Examples

以下是使用“需要批准”任务的一些实际示例:

🌐 Here are some practical examples of using the Require Approval job:

在部署到生产环境之前请求批准

此工作流将 Web 应用部署到预览环境,然后在部署到生产环境之前需要用户批准。

🌐 This workflow deploys a web app to preview and then requires approval from a user before deploying to production.

.eas/workflows/web.yml
jobs: web_preview: name: Deploy Web Preview type: deploy require_approval: name: Deploy Web to Production? needs: [web_preview] type: require-approval web_production: name: Deploy Web Production needs: [require_approval] type: deploy params: prod: true
工作流的控制流

此工作流程允许用户在揭示结局之前,通过要求批准来决定故事如何结束。

🌐 This workflow lets a user decide how the story ends by requiring approval before revealing the conclusion.

.eas/workflows/dragon-knight-interactive.yml
jobs: show_story_intro: name: Dragon and Knight Story Intro type: doc params: md: | # The Dragon and the Knight Once upon a time, in a land far away, a brave knight set out to face a mighty dragon. The dragon roared, breathing fire across the valley, but the knight stood firm, shield raised high. Now, the fate of their encounter is in your hands... require_approval: name: Should the knight and dragon become friends? needs: [show_story_intro] type: require-approval happy_ending: name: Friendship Ending needs: [require_approval] type: doc params: md: | ## A New Friendship The knight lowered his sword, and the dragon ceased its fire. They realized they both longed for peace. From that day on, they became the best of friends, protecting the kingdom together. epic_battle: name: Epic Battle Ending after: [require_approval] if: ${{ failure() }} type: doc params: md: | ## The Epic Battle The knight charged forward, and the dragon unleashed a mighty roar. Their battle shook the mountains and echoed through the ages. In the end, both were remembered as fierce and noble adversaries.

文档

🌐 Doc

在工作流日志中显示 Markdown 部分。

🌐 Displays a Markdown section in the workflow logs.

语法

🌐 Syntax

jobs: show_whats_next: type: doc params: md: string

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

参数类型描述
mdstring必填。要显示的 Markdown 内容。你可以使用 ${{ ... }} 工作流插值。

示例

🌐 Examples

以下是一些使用文档工作的实际例子:

🌐 Here are some practical examples of using the Doc job:

显示说明

此工作流程会构建一个 iOS 应用,然后在工作流程日志中显示一个 Markdown 部分。

🌐 This workflow builds an iOS app and then displays a Markdown section in the workflow logs.

.eas/workflows/build-and-submit-ios.yml
jobs: build_ios: name: Build iOS type: build params: platform: ios profile: production submit: name: Submit to App Store type: submit needs: [build_ios] params: build_id: ${{ needs.build_ios.outputs.build_id }} profile: production next_steps: name: Next Steps needs: [submit] type: doc params: md: | # To do next Your app has just been sent to [App Store Connect](https://appstoreconnect.apple.com/apps). 1. Download the app from TestFlight. 2. Test the app a bunch. 3. Submit the app for review.

重新打包

🌐 Repack

从现有构建中重新打包应用。此任务会重新打包应用的元数据和 JavaScript 包,而无需执行完整的原生重建,这对于创建与特定指纹兼容的更快速构建非常有用。

🌐 Repackages an app from an existing build. This job repackages the app's metadata and JavaScript bundle without performing a full native rebuild, which is useful for creating a faster build compatible with a specific fingerprint.

语法

🌐 Syntax

jobs: repack: type: repack runs_on: string # optional - see https://expo.nodejs.cn/build-reference/infrastructure/ for available options params: build_id: string # required profile: string # optional embed_bundle_assets: boolean # optional message: string # optional repack_version: string # optional

常见问题

🌐 Common questions

什么时候使用 repack,什么时候不使用?

重新封装工作适用于以下情况:

🌐 Repack job is suitable for the following use cases:

  • 通过重用现有构建来减少 CI 构建时间
  • 在需要时触发完整的本地构建
  • 为你的团队提供更快速的反馈循环

重新封装工作不适用于以下情况:

🌐 Repack job is not suitable for the following use cases:

  • 生产版本需要通过完整的构建流程以确保符号化和应用签名正确

参数

🌐 Parameters

你可以将以下参数传递到 params 列表中:

🌐 You can pass the following parameters into the params list:

ParameterTypeDescription
build_idstringRequired. The source build ID of the build to repack.
profilestringOptional. The build profile to use. Defaults to the profile of the source build retrieved from build_id.
embed_bundle_assetsbooleanOptional. Whether to embed the bundle assets in the repacked build. By default, this is automatically determined based on the source build.
messagestringOptional. Custom message attached to the build. Corresponds to the --message flag when running eas build.
repack_versionstringOptional. The version of the @expo/repack-app to use. Defaults to the latest version.

示例

🌐 Examples

以下是使用指纹与重打包任务的一些实际示例:

🌐 Here are some practical examples of using the Fingerprint with Repack jobs:

使用指纹和重打包的持续部署

此工作流程首先生成指纹,然后根据是否已存在与该指纹兼容的构建来构建或重新打包应用。最后,它运行 Maestro 测试。

🌐 This workflow first generates a fingerprint and then builds or repacks the app depending on whether a compatible build for that fingerprint already exists. Finally, it runs Maestro tests.

.eas/workflows/cd-fingerprint-repack.yml
name: continuous-deploy-fingerprint jobs: fingerprint: id: fingerprint type: fingerprint environment: production android_get_build: needs: [fingerprint] id: android_get_build type: get-build params: fingerprint_hash: ${{ needs.fingerprint.outputs.android_fingerprint_hash }} platform: android android_repack: needs: [android_get_build] id: android_repack if: ${{ needs.android_get_build.outputs.build_id }} type: repack params: build_id: ${{ needs.android_get_build.outputs.build_id }} android_build: needs: [android_get_build] id: android_build if: ${{ !needs.android_get_build.outputs.build_id }} type: build params: platform: android profile: preview-simulator android_maestro: after: [android_repack, android_build] id: android_maestro type: maestro image: latest params: build_id: ${{ needs.android_repack.outputs.build_id || needs.android_build.outputs.build_id }} flow_path: ['maestro.yaml'] ios_get_build: needs: [fingerprint] id: ios_get_build type: get-build params: fingerprint_hash: ${{ needs.fingerprint.outputs.ios_fingerprint_hash }} platform: ios ios_repack: needs: [ios_get_build] id: ios_repack if: ${{ needs.ios_get_build.outputs.build_id }} type: repack params: build_id: ${{ needs.ios_get_build.outputs.build_id }} ios_build: needs: [ios_get_build] id: ios_build if: ${{ !needs.ios_get_build.outputs.build_id }} type: build params: platform: ios profile: preview-simulator ios_maestro: after: [ios_repack, ios_build] id: ios_maestro type: maestro image: latest params: build_id: ${{ needs.ios_repack.outputs.build_id || needs.ios_build.outputs.build_id }} flow_path: ['maestro.yaml']