EAS 工作流程的语法
EAS Workflows 配置文件语法的参考指南。
工作流是由一个或多个作业组成的可配置自动化过程。你必须创建一个 YAML 文件来定义你的工作流配置。
¥A workflow is a configurable automated process made up of one or more jobs. You must create a YAML file to define your workflow configuration.
要开始使用工作流,请参阅 开始使用 EAS 工作流 或参阅 示例 了解完整的工作流配置。
¥To get started with workflows, see Get Started with EAS Workflows or see Examples for complete workflow configurations.
工作流文件
¥Workflow files
工作流文件使用 YAML 语法,必须具有 .yml
或 .yaml
文件扩展名。如果你是 YAML 新手并想了解更多信息,请参阅 在 Y 分钟内学习 YAML。
¥Workflow files use YAML syntax and must have either a .yml
or .yaml
file extension. If you're new to YAML and want to learn more, see Learn YAML in Y minutes.
工作流文件位于项目中的 .eas/workflows 目录中。.eas 目录应与你的 eas.json 文件处于同一级别。
¥Workflow files are located in the .eas/workflows directory in your project. The .eas directory should be at the same level as your eas.json file.
例如:
¥For example:
my-app
.eas
workflows
create-development-builds.yml
publish-preview-update.yml
deploy-to-production.yml
eas.json
配置参考
¥Configuration Reference
以下是工作流配置文件语法的参考。
¥Below is a reference for the syntax of the workflow configuration file.
name
工作流的人性化名称。此 SDK 显示在工作流列表页面的 EAS 仪表板上,是工作流详情页面的标题。
¥The human-friendly name of the workflow. This is displayed on the EAS dashboard on the workflows list page and is the title of the workflow's detail page.
name: My workflow
on
on
键定义哪些 GitHub 事件触发工作流。任何工作流程都可以使用 eas workflow:run
命令触发,无论 on
密钥如何。
¥The on
key defines which GitHub events trigger the workflow. Any workflow can be triggered with the eas workflow:run
command, regardless of the on
key.
on:
# Trigger on pushes to main branch
push:
branches:
- main
# And on pull requests starting with 'version-'
pull_request:
branches:
- version-*
on.push
当拉取请求带有匹配标签时运行你的工作流程。
¥Runs your workflow when you push a commit to matching branches and/or tags.
使用 branches
列表,你只能在推送到那些指定的分支时触发工作流。例如,如果你使用 branches: ['main']
,则只有推送到 main
分支才会触发工作流程。支持 glob。使用 !
前缀,你可以指定要忽略的分支(即使没有该分支,你仍然需要提供至少一个分支模式)。
¥With the branches
list, you can trigger the workflow only when those specified branches are pushed to. For example, if you use branches: ['main']
, only pushes to the main
branch will trigger the workflow. Supports globs. By using the !
prefix you can specify branches to ignore (you still need to provide at least one branch pattern without it).
使用 tags
列表,你只能在推送指定的标签时触发工作流程。例如,如果你使用 tags: ['v1']
,则只有推送的 v1
标签才会触发工作流程。支持 glob。使用 !
前缀,你可以指定要忽略的标签(即使没有该标签,你仍然需要提供至少一个标签模式)。
¥With the tags
list, you can trigger the workflow only when those specified tags are pushed. For example, if you use tags: ['v1']
, only the v1
tag being pushed will trigger the workflow. Supports globs. By using the !
prefix you can specify tags to ignore (you still need to provide at least one tag pattern without it).
使用 paths
列表,你仅可在对与指定路径匹配的文件进行更改时触发工作流。例如,如果你使用 paths: ['apps/mobile/**']
,则只有更改 apps/mobile
目录中的文件才会触发工作流。支持 glob。默认情况下,更改任何路径都会触发此工作流。
¥With the paths
list, you can trigger the workflow only when changes are made to files matching the specified paths. For example, if you use paths: ['apps/mobile/**']
, only changes to files in the apps/mobile
directory will trigger the workflow. Supports globs. By default, changes to any path will trigger the workflow.
当未提供 branches
和 tags
时,branches
默认为 ['*']
,tags
默认为 []
,这意味着工作流将在推送事件到所有分支时触发,而不会在标签推送时触发。如果仅提供两个列表中的一个,则另一个默认为 []
。
¥When neither branches
nor tags
are provided, branches
defaults to ['*']
and tags
defaults to []
, which means the workflow will trigger on push events to all branches and will not trigger on tag pushes. If only one of the two lists is provided the other defaults to []
.
on:
push:
branches:
- main
- feature/**
- !feature/test-** # other branch names and globs
tags:
- v1
- v2*
- !v2-preview** # other tag names and globs
paths:
- apps/mobile/**
- packages/shared/**
- !**/*.md # ignore markdown files
on.pull_request
当你创建或更新针对匹配分支之一的拉取请求时,运行你的工作流。
¥Runs your workflow when you create or update a pull request that targets one of the matching branches.
使用 branches
列表,你只能在指定的分支是拉取请求的目标时触发工作流程。例如,如果你使用 branches: ['main']
,则只有合并到主分支的拉取请求才会触发工作流程。支持 glob。未提供时默认为 ['*']
,这意味着工作流将在所有分支的拉取请求事件上触发。使用 !
前缀,你可以指定要忽略的分支(即使没有该分支,你仍然需要提供至少一个分支模式)。
¥With the branches
list, you can trigger the workflow only when those specified branches are the target of the pull request. For example, if you use branches: ['main']
, only pull requests to merge into the main branch will trigger the workflow. Supports globs. Defaults to ['*']
when not provided, which means the workflow will trigger on pull request events to all branches. By using the !
prefix you can specify branches to ignore (you still need to provide at least one branch pattern without it).
使用 types
列表,你只能在指定的拉取请求事件类型上触发工作流。例如,如果你使用 types: ['opened']
,则只有 pull_request.opened
事件(首次打开拉取请求时发送)才会触发工作流。未提供时默认为 ['opened', 'reopened', 'synchronize']
。支持的事件类型:
¥With the types
list, you can trigger the workflow only on the specified pull request event types. For example, if you use types: ['opened']
, only the pull_request.opened
event (sent when a pull request is first opened) will trigger the workflow. Defaults to ['opened', 'reopened', 'synchronize']
when not provided. Supported event types:
-
opened
-
reopened
-
synchronize
-
labeled
使用 paths
列表,你仅可在对与指定路径匹配的文件进行更改时触发工作流。例如,如果你使用 paths: ['apps/mobile/**']
,则只有更改 apps/mobile
目录中的文件才会触发工作流。支持 glob。默认情况下,更改任何路径都会触发此工作流。
¥With the paths
list, you can trigger the workflow only when changes are made to files matching the specified paths. For example, if you use paths: ['apps/mobile/**']
, only changes to files in the apps/mobile
directory will trigger the workflow. Supports globs. By default, changes to any path will trigger the workflow.
on:
pull_request:
branches:
- main
- feature/**
- !feature/test-** # other branch names and globs
types:
- opened
# other event types
paths:
- apps/mobile/**
- packages/shared/**
- !**/*.md # ignore markdown files
on.pull_request_labeled
当匹配分支上发生拉取请求事件时运行你的工作流程。
¥Runs your workflow when a pull request is labeled with a matching label.
使用 labels
列表,你可以指定哪些标签在分配给你的拉取请求时会触发工作流。例如,如果你使用 labels: ['Test']
,则只有使用 Test
标签标记拉取请求才会触发工作流。未提供时默认为 []
,这意味着没有标签会触发工作流。
¥With the labels
list, you can specify which labels, when assigned to your pull request, will trigger the workflow. For example, if you use labels: ['Test']
, only labeling a pull request with the Test
label will trigger the workflow. Defaults to []
when not provided, which means no labels will trigger the workflow.
你还可以直接向 on.pull_request_labeled
提供匹配标签列表,以获得更简单的语法。
¥You can also provide a list of matching labels directly to on.pull_request_labeled
for simpler syntax.
on:
pull_request_labeled:
labels:
- Test
- Preview
# other labels
或者:
¥Alternatively:
on:
pull_request_labeled:
- Test
- Preview
# other labels
on.schedule.cron
使用 unix-cron 语法按计划运行你的工作流。你可以使用 crontab 专家 及其 examples 生成 cron 字符串。
¥Runs your workflow on a schedule using unix-cron syntax. You can use crontab guru and their examples to generate cron strings.
-
计划的工作流仅在代码库的默认分支上运行。在许多情况下,这意味着
main
分支上工作流文件中的 cron 将被调度,而功能分支中工作流文件中的 cron 将不会被调度。¥Scheduled workflows will only run on the default branch of the repository. In many cases, this means crons inside workflow files on the
main
branch will be scheduled, while crons inside workflow files in feature branches will not be scheduled. -
在高负载期间,计划的工作流可能会延迟。高加载时间包括每小时的开始时间。在极少数情况下,作业可能会被跳过或多次运行。确保你的工作流程是幂等的,并且没有有害的副作用。
¥Scheduled workflows may be delayed during periods of high load. High load times include the start of every hour. In rare circumstances, jobs may be skipped or run multiple times. Make sure that your workflows are idempotent and do not have harmful side effects.
-
一个工作流可以有多个
cron
计划。¥A workflow can have multiple
cron
schedules. -
计划的工作流在 GMT 时区运行。
¥Scheduled workflows run in the GMT time zone.
on:
schedule:
- cron: '0 0 * * *' # Runs at midnight GMT every day
jobs
工作流程运行由一个或多个作业组成。
¥A workflow run is made up of one or more jobs.
jobs:
job_1:
# ...
job_2:
# ...
jobs.<job_id>
每个作业都必须有一个 ID。ID 在工作流中应该是唯一的,并且可以包含字母数字字符和下划线。例如,以下 YAML 中的 my_job
:
¥Each job must have an ID. The ID should be unique within the workflow and can contain alphanumeric characters and underscores. For example, my_job
in the following YAML:
jobs:
my_job:
# ...
jobs.<job_id>.name
工作流详细信息页面上显示的作业的人性化名称。
¥The human-friendly name of the job displayed on the workflow's detail page.
jobs:
my_job:
name: Build app
jobs.<job_id>.environment
为作业设置 EAS 环境变量 环境。有三个可能的值:
¥Sets the EAS environment variable environment for the job. There are three possible values:
-
production
(默认)¥
production
(default) -
preview
-
development
environment
键可用于除预打包的 build
、submit
和 get-build
作业之外的所有作业。
¥The environment
key is available on all jobs except for the pre-packaged build
, submit
, and get-build
jobs.
jobs:
my_job:
environment: production | preview | development
jobs.<job_id>.defaults.run.working_directory
为作业中的所有步骤设置运行命令的目录。
¥Sets the directory to run commands in for all steps in the job.
jobs:
my_job:
defaults:
run:
working_directory: ./my-app
steps:
- name: My first step
run: pwd # prints: /home/expo/workingdir/build/my-app
defaults
用作工作流配置中定义的所有作业的默认值的参数。
¥Parameters to use as defaults for all jobs defined in the workflow configuration.
defaults.run.working_directory
运行脚本的默认工作目录。相对路径(如 "./assets" 或 "assets")从应用的基本目录中解析。
¥Default working directory to run the scripts in. Relative paths like "./assets" or "assets" are resolved from the app's base directory.
defaults.tools
应用于此工作流配置中定义的作业的特定版本的工具。请遵循每个工具的文档以了解可用值。
¥Specific versions of tools that should be used for jobs defined in this workflow configuration. Follow each tool's documentation for available values.
工具 | 描述 |
---|---|
node | 通过 nvm 安装的 Node.js 版本。 |
yarn | 通过 npm -g 安装的 Yarn 版本。 |
corepack | 如果设置为 true ,corepack 将在构建过程开始时启用。默认为 false。 |
pnpm | 通过 npm -g 安装的 pnpm 版本。 |
bun | 通过将 bun-v$VERSION 传递给 Bun 安装脚本安装的 Bun 版本。 |
ndk | 通过 sdkmanager 安装的 Android NDK 版本。 |
bundler | 将传递给 gem install -v 的 Bundler 版本。 |
fastlane | 将传递给 gem install -v 的 fastlane 版本。 |
cocoapods | 将传递给 gem install -v 的 CocoaPods 版本。 |
使用 defaults.tools
的工作流程示例:
¥Example of workflow using defaults.tools
:
name: Set up custom versions
defaults:
tools:
node: latest
yarn: '2'
corepack: true
pnpm: '8'
bun: '1.0.0'
fastlane: 2.224.0
cocoapods: 1.12.0
on:
push:
branches: ['*']
jobs:
setup:
steps:
- name: Check Node version
run: node --version # should print a concrete version, like 23.9.0
- name: Check Yarn version
run: yarn --version # should print a concrete version, like 2.4.3
concurrency
并发控制配置。目前仅允许为同一分支的工作流设置 cancel_in_progress
。
¥Configuration for concurrency control. Currently only allows setting cancel_in_progress
for same-branch workflows.
concurrency:
cancel_in_progress: true
group: ${{ workflow.filename }}-${{ github.ref }}
属性 | 类型 | 描述 |
---|---|---|
cancel_in_progress | boolean | 如果设置为 true,从 GitHub 启动的新工作流程运行将取消同一分支当前正在进行的运行。 |
group | string | 我们目前不支持自定义并发组。设置此占位符值,以便在我们支持自定义组时,你的工作流程仍然兼容。 |
控制流
¥Control flow
你可以使用 needs
和 after
关键字控制作业的运行时间。此外,你可以使用 if
关键字来控制是否应根据条件运行作业。
¥You can control when a job runs with the needs
and after
keywords. In addition, you can use the if
keyword to control whether a job should run based on a condition.
jobs.<job_id>.needs
作业 ID 列表,这些作业必须先成功完成,然后此作业才会运行。
¥A list of job IDs whose jobs must complete successfully before this job will run.
jobs:
test:
steps:
- uses: eas/checkout
- uses: eas/use_npm_token
- uses: eas/install_node_modules
- name: tsc
run: yarn tsc
build:
needs: [test] # This job will only run if the 'test' job succeeds
type: build
params:
platform: ios
jobs.<job_id>.after
在运行此作业之前必须完成(成功或失败)的作业 ID 列表。
¥A list of job IDs that must complete (successfully or not) before this job will run.
jobs:
build:
type: build
params:
platform: ios
notify:
after: [build] # This job will run after build completes (whether build succeeds or fails)
jobs.<job_id>.if
if
条件确定是否应运行作业。当满足 if
条件时,作业将运行。当不满足条件时,将跳过作业。跳过的作业不会成功完成,并且任何在其 needs
列表中包含此作业的下游作业都不会运行。
¥The if
conditional determines if a job should run. When an if
condition is met, the job will run. When the condition is not met, the job will be skipped. A skipped job won't have completed successfully and any downstream jobs will not run that have this job in their needs
list.
jobs:
my_job:
if: ${{ github.ref_name == 'main' }}
插值
¥Interpolation
你可以根据工作流运行的上下文自定义工作流的行为,包括要执行的命令、控制流、环境变量、构建配置文件、应用版本等等。
¥You can customize the behavior of a workflow — commands to execute, control flow, environment variables, build profile, app version, and more — based on the workflow run's context.
after
和 needs
¥after
and needs
当你在 after
或 needs
中指定上游作业时,你可以在下游作业中使用其输出。所有作业都公开 status
属性。大多数预打包的作业也会公开一些输出。你可以 使用 set-output
函数在自定义任务中设置输出。
¥When you specify an upstream job in after
or needs
, you can use its outputs in a downstream job. All jobs expose a status
property. Most pre-packaged jobs also expose some outputs. You can set outputs in custom jobs using the set-output
function.
{
"status": "success" | "failure" | "skipped",
"outputs": {}
}
用法示例:
¥Example usage:
jobs:
setup:
outputs:
date: ${{ steps.current_date.outputs.date }}
steps:
- id: current_date
run: |
DATE=$(date +"%Y.%-m.%-d")
set-output date "$DATE"
build_ios:
needs: [setup]
type: build
env:
# You might use process.env.VERSION_SUFFIX to customize
# app version in your dynamic app config.
VERSION_SUFFIX: ${{ needs.setup.outputs.date }}
params:
platform: ios
profile: development
github
为了简化从 GitHub Actions 到 EAS Workflows 的迁移,我们公开了一些你可能会觉得有用的上下文字段。
¥To ease the migration from GitHub Actions to EAS Workflows we expose some context fields you may find useful.
{
"event_name": "pull_request" | "push" | "schedule" | "workflow_dispatch",
"sha": string,
"ref": string, // e.g. refs/heads/main
"ref_name": string, // e.g. main
"ref_type": "branch" | "tag" | "other"
}
如果工作流程运行从 eas workflow:run
开始,则其 event_name
将为 workflow_dispatch
,其余所有属性将为空。
¥If a workflow run is started from eas workflow:run
, its event_name
will be workflow_dispatch
and all the rest of the properties will be empty.
用法示例:
¥Example usage:
jobs:
build_ios:
type: build
if: ${{ github.ref_name == 'main' }}
params:
platform: ios
profile: production
success()
, failure()
仅当先前的任务均未失败时,success()
才返回 true
。如果先前的任何任务失败,failure()
将返回 true
。
¥success()
returns true
only if no previous job has failed. failure()
returns true
if any previous job has failed.
fromJSON()
, toJSON()
fromJSON()
是 JSON.parse()
,toJSON()
是 JSON.stringify()
。你可以使用它们来消费或生成 JSON 输出。
¥fromJSON()
is JSON.parse()
, and toJSON()
is JSON.stringify()
. You can use them to consume or produce JSON outputs.
用法示例:
¥Example usage:
jobs:
publish_update:
type: update
print_debug_info:
needs: [publish_update]
steps:
- run: |
echo "First update group: ${{ needs.publish_update.outputs.first_update_group_id }}"
echo "Second update group: ${{ fromJSON(needs.publish_update.outputs.updates_json || '[]')[1].group }}"
预打包作业
¥Pre-packaged jobs
jobs.<job_id>.type
指定要运行的预打包作业的类型。预打包的作业根据工作流详细信息页面上的作业类型生成专门的 UI。
¥Specifies the type of pre-packaged job to run. Pre-packaged jobs produce specialized UI according to the type of job on the workflow's detail page.
jobs:
my_job:
type: build
了解以下不同的预打包作业。
¥Learn about the different pre-packaged jobs below.
build
使用 EAS 构建 创建项目的 Android 或 iOS 版本。有关详细信息和示例,请参阅 构建任务文档。
¥Creates an Android or iOS build of your project using EAS Build. See Build job documentation for detailed information and examples.
jobs:
my_job:
type: build
params:
platform: ios | android # required
profile: string # optional, default: production
此作业输出以下属性:
¥This job outputs the following properties:
{
"build_id": string,
"app_build_version": string | null,
"app_identifier": string | null,
"app_version": string | null,
"channel": string | null,
"distribution": "internal" | "store" | null,
"fingerprint_hash": string | null,
"git_commit_hash": string | null,
"platform": "ios" | "android" | null,
"profile": string | null,
"runtime_version": string | null,
"sdk_version": string | null,
"simulator": "true" | "false" | null
}
deploy
使用 EAS 托管 部署你的应用。有关详细信息和示例,请参阅 部署任务文档。
¥Deploys your application using EAS Hosting. See Deploy job documentation for detailed information and examples.
jobs:
my_job:
type: deploy
params:
alias: string # optional
prod: boolean # optional
fingerprint
计算项目的指纹。有关详细信息和示例,请参阅 指纹任务文档。
¥Calculates a fingerprint of your project. See Fingerprint job documentation for detailed information and examples.
jobs:
my_job:
type: fingerprint
params:
environment: production | preview | development # optional, defaults to production
env: # optional
APP_VARIANT: staging # just an example
此作业输出以下属性:
¥This job outputs the following properties:
{
"android_fingerprint_hash": string,
"ios_fingerprint_hash": string,
}
get-build
从 EAS 中检索与提供的参数匹配的现有构建。有关详细信息和示例,请参阅 获取构建任务文档。
¥Retrieves an existing build from EAS that matches the provided parameters. See Get Build job documentation for detailed information and examples.
jobs:
my_job:
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
此作业输出以下属性:
¥This job outputs the following properties:
{
"build_id": string,
"app_build_version": string | null,
"app_identifier": string | null,
"app_version": string | null,
"channel": string | null,
"distribution": "internal" | "store" | null,
"fingerprint_hash": string | null,
"git_commit_hash": string | null,
"platform": "ios" | "android" | null,
"profile": string | null,
"runtime_version": string | null,
"sdk_version": string | null,
"simulator": "true" | "false" | null
}
submit
使用 EAS 提交 向应用商店提交 Android 或 iOS 版本。有关详细信息和示例,请参阅 提交任务文档。
¥Submits an Android or iOS build to the app store using EAS Submit. See Submit job documentation for detailed information and examples.
jobs:
my_job:
type: submit
params:
build_id: string # required
profile: string # optional, default: production
此作业输出以下属性:
¥This job outputs the following properties:
{
"apple_app_id": string | null, // Apple App ID. https://expo.fyi/asc-app-id
"ios_bundle_identifier": string | null, // iOS bundle identifier of the submitted build. https://expo.fyi/bundle-identifier
"android_package_id": string | null // Submitted Android package ID. https://expo.fyi/android-package
}
update
使用 EAS 更新 发布更新。有关详细信息和示例,请参阅 更新任务文档。
¥Publishes an update using EAS Update. See Update job documentation for detailed information and examples.
jobs:
my_job:
type: update
params:
message: string # optional
platform: string # optional - android | ios | all, defaults to all
branch: string # optional
channel: string # optional - cannot be used with branch
此作业输出以下属性:
¥This job outputs the following properties:
{
"first_update_group_id": string, // ID of the first update group. You can use it to e.g. construct the update URL for a development client deep link.
"updates_json": string // Stringified JSON array of update groups. Output of `eas update --json`.
}
maestro
运行 大师 并在编译之前删除生成的原生目录。有关详细信息和示例,请参阅 Maestro 任务文档。
¥Runs Maestro tests on a build. See Maestro job documentation for detailed information and examples.
Maestro 测试是实验性的,可能会出现不稳定的情况。
jobs:
my_job:
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. If true, uploads a screen recording of the tests.
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_system_image_package: string # optional. Android emulator system image package to use.
device_identifier: string | { android?: string, ios?: string } # optional. Device identifier to use for the tests.
maestro-cloud
在 Maestro 云 中的版本上运行 大师 测试。有关详细信息和示例,请参阅 Maestro 云任务文档。
¥Runs Maestro tests on a build in Maestro Cloud. See Maestro Cloud job documentation for detailed information and examples.
在 Maestro Cloud 中运行测试需要 Maestro Cloud 账户和云计划订阅。转到 Maestro 文档 了解更多信息。
jobs:
my_job:
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. 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_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.
slack
使用 webhook URL 向 Slack 通道发送消息。有关详细信息和示例,请参阅 Slack 任务文档。
¥Sends a message to a Slack channel using a webhook URL. See Slack job documentation for detailed information and examples.
jobs:
my_job:
type: slack
params:
webhook_url: string # required
message: string # required if payload is not provided
payload: object # required if message is not provided
require-approval
继续工作流程之前需要获得用户的批准。用户可以批准或拒绝,这意味着作业成功或失败。有关详细信息和示例,请参阅 需要审批任务文档。
¥Requires approval from a user before continuing with the workflow. A user can approve or reject which translates to success or failure of the job. See Require Approval job documentation for detailed information and examples.
jobs:
confirm:
type: require-approval
doc
在工作流日志中显示 Markdown 部分。有关详细信息和示例,请参阅 文档任务文档。
¥Displays a Markdown section in the workflow logs. See Doc job documentation for detailed information and examples.
jobs:
next_steps:
type: doc
params:
md: string
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. See Repack job documentation for detailed information and examples.
jobs:
next_steps:
type: repack
params:
build_id: string
自定义作业
¥Custom jobs
在构建上运行 测试。不需要 type
字段。
¥Runs custom code and can use built-in EAS functions. Does not require a type
field.
jobs:
my_job:
steps:
# ...
jobs.<job_id>.steps
作业包含名为 steps
的一系列任务。步骤可以运行命令。steps
只能在自定义作业和 build
作业中提供。
¥A job contains a sequence of tasks called steps
. Steps can run commands. steps
may only be provided in custom jobs and build
jobs.
jobs:
my_job:
steps:
- name: My first step
run: echo "Hello World"
jobs.<job_id>.outputs
由作业定义的输出列表。这些输出可供所有依赖于此作业的下游作业访问。要设置输出,请在作业步骤中使用 set-output
函数。
¥A list of outputs defined by the job. These outputs are accessible to all downstream jobs that depend on this job. To set outputs, use the set-output
function within a job step.
下游作业可以在 插值上下文 中使用以下表达式访问这些输出:
¥Downstream jobs can access these outputs using the following expressions within interpolation contexts:
-
needs.<job_id>.outputs.<output_name>
-
after.<job_id>.outputs.<output_name>
其中,<job_id>
指的是上游作业的标识符,<output_name>
指的是你要访问的特定输出变量。
¥Here, <job_id>
refers to the identifier of the upstream job, and <output_name>
refers to the specific output variable you want to access.
在下面的示例中,set-output
函数在 job_1
的 step_1
步骤中将名为 test
的输出设置为值 hello world
。稍后在 job_2
中,使用 needs.job_1.outputs.output_1
在 step_2
中访问它。
¥In the example below, the set-output
function sets the output named test
to the value hello world
in job_1
's step_1
step. Later in job_2
, it's accessed in step_2
using needs.job_1.outputs.output_1
.
jobs:
job_1:
outputs:
output_1: ${{ steps.step_1.outputs.test }}
steps:
- id: step_1
run: set-output test "hello world"
job_2:
needs: [job_1]
steps:
- id: step_2
run: echo ${{ needs.job_1.outputs.output_1 }}
jobs.<job_id>.image
指定用于该任务的虚拟机映像。查看 基础设施 获取可用图片。
¥Specifies the VM image to use for the job. See Infrastructure for available images.
jobs:
my_job:
image: auto | string # optional, defaults to 'auto'
jobs.<job_id>.runs_on
指定将执行作业的工作线程。仅适用于自定义作业。
¥Specifies the worker that will execute the job. Available only on custom jobs.
jobs:
my_job:
runs_on: linux-medium | linux-large |
linux-medium-nested-virtualization |
linux-large-nested-virtualization |
macos-medium | macos-large # optional, defaults to linux-medium
Worker | vCPU | 内存(GiB RAM) | SSD (GiB) | 注释 |
---|---|---|---|---|
linux-medium | 4 | 16 | 14 | 默认工作器。 |
linux-large | 8 | 32 | 28 | |
linux-medium-nested-virtualization | 4 | 16 | 14 | 允许运行 Android 模拟器。 |
linux-large-nested-virtualization | 4 | 32 | 28 | 允许运行 Android 模拟器。 |
Worker | 效率核心 | 统一内存 (GiB RAM) | SSD (GiB) | 注释 |
---|---|---|---|---|
macos-medium | 5 | 20 | 125 | 运行 iOS 作业,包括模拟器。 |
macos-large | 10 | 40 | 125 | 运行 iOS 作业,包括模拟器。 |
注意:对于 Android 模拟器作业,你必须使用
linux-*-nested-virtualization
工作器。对于 iOS 构建和 iOS 模拟器作业,你必须使用macos-*
工作者。¥Note: For Android Emulator jobs, you must use a
linux-*-nested-virtualization
worker. For iOS builds and iOS Simulator jobs, you must use amacos-*
worker.
jobs.<job_id>.steps.<step>.id
id
属性用于引用作业中的步骤。用于在下游作业中使用步骤的输出。
¥The id
property is used to reference the step in the job. Useful for using the step's output in a downstream job.
jobs:
my_job:
outputs:
test: ${{ steps.step_1.outputs.test }} # References the output from step_1
steps:
- id: step_1
run: set-output test "hello world"
jobs.<job_id>.steps.<step>.name
步骤的人性化名称,显示在作业的日志中。如果未提供步骤的名称,则使用 run
命令作为步骤名称。
¥The human-friendly name of the step, which is displayed in the job's logs. When a step's name is not provided, the run
command is used as the step name.
jobs:
my_job:
steps:
- name: My first step
run: echo "Hello World"
jobs.<job_id>.steps.<step>.run
在步骤中运行的 shell 命令。
¥The shell command to run in the step.
jobs:
my_job:
steps:
- run: echo "Hello World"
jobs.<job_id>.steps.<step>.shell
用于运行命令的 shell。默认为 bash
。
¥The shell to use for running the command. Defaults to bash
.
jobs:
my_job:
steps:
- run: echo "Hello World"
shell: bash
jobs.<job_id>.steps.<step>.working_directory
运行命令的目录。在步骤级别定义时,如果作业上也定义了 jobs.<job_id>.defaults.run.working_directory
设置,它将覆盖该设置。
¥The directory to run the command in. When defined at the step level, it overrides the jobs.<job_id>.defaults.run.working_directory
setting on the job if it is also defined.
jobs:
my_job:
steps:
- uses: eas/checkout
- run: pwd # prints: /home/expo/workingdir/build/my-app
working_directory: ./my-app
jobs.<job_id>.steps.<step>.uses
EAS 提供了一组内置可重用函数,你可以在工作流步骤中使用它们。uses
关键字用于指定要使用的函数。所有内置函数都以 eas/
前缀开头。
¥EAS provides a set of built-in reusable functions that you can use in workflow steps. The uses
keyword is used to specify the function to use. All built-in functions start with the eas/
prefix.
jobs:
my_job:
steps:
- uses: eas/checkout
- uses: eas/install_node_modules
- uses: eas/prebuild
- name: List files
run: ls -la
以下是你可以在工作流步骤中使用的内置函数列表。
¥Below is a list of built-in functions you can use in your workflow steps.
eas/checkout
签出你的项目源文件。
¥Checks out your project source files.
jobs:
my_job:
steps:
- uses: eas/checkout
在 GitHub 上查看 eas/checkout 函数的源代码。
eas/install_node_modules
使用根据你的项目检测到的包管理器(bun、npm、pnpm 或 Yarn)安装 node_modules。与 monorepos 一起使用。
¥Installs node_modules using the package manager (bun, npm, pnpm, or Yarn) detected based on your project. Works with monorepos.
jobs:
my_job:
steps:
- uses: eas/checkout
- uses: eas/install_node_modules
在 GitHub 上查看 eas/install_node_modules 函数的源代码。
eas/download_build
下载指定版本的应用存档。默认情况下,下载的工件可以是 .apk、.aab、.ipa 或 .app 文件,也可以是包含一个或多个这些文件的 .tar.gz 压缩包。如果工件是 .tar.gz 存档,它将被解压并返回第一个与指定扩展名匹配的文件。如果构建没有生成应用存档,则该步骤将失败。
¥Downloads application archive of a given build. By default, the downloaded artifact can be an .apk, .aab, .ipa, or .app file, or a .tar.gz archive containing one or more of these files. If the artifact is a .tar.gz archive, it will be extracted and the first file matching the specified extensions will be returned. If the build produced no application archive, the step will fail.
jobs:
my_job:
steps:
- uses: eas/download_build
with:
build_id: string # Required. ID of the build to download.
extensions: [apk, aab, ipa, app] # Optional. List of file extensions to look for. Defaults to ["apk", "aab", "ipa", "app"].
属性 | 类型 | 必需的 | 默认 | 描述 |
---|---|---|---|---|
build_id | string | 是 | – | 要下载的构建版本的 ID。必须是有效的 UUID。 |
extensions | string[] | 否 | ["apk", "aab", "ipa", "app"] | 在下载的工件或存档中查找的文件扩展名列表。 |
输出:
¥Outputs:
-
artifact_path
:匹配应用归档的绝对路径。此输出可用作工作流程中其他步骤的输入。例如,上传或进一步处理工件。¥
artifact_path
: The absolute path to the matching application archive. This output can be used as input into other steps in your workflow. For example, to upload or process the artifact further.
用法示例:
¥Example usage:
jobs:
build_ios:
type: build
params:
platform: ios
profile: production
my_job:
needs: [build_ios]
steps:
- uses: eas/download_build
id: download_build
with:
build_id: ${{ needs.build_ios.outputs.build_id }}
- name: Print artifact path
run: |
echo "Artifact path: ${{ steps.download_build.outputs.artifact_path }}"
在 GitHub 上查看 eas/download_build 函数的源代码。
eas/prebuild
运行 iOS 作业,包括模拟器。
¥Runs the expo prebuild
command using the package manager (bun, npm, pnpm, or Yarn) detected based on your project with the command best suited for your build type and build environment.
jobs:
my_job:
steps:
- uses: eas/checkout
- uses: eas/install_node_modules
- uses: eas/prebuild
jobs:
my_job:
steps:
- uses: eas/checkout
- uses: eas/install_node_modules
- uses: eas/resolve_apple_team_id_from_credentials
id: resolve_apple_team_id_from_credentials
- uses: eas/prebuild
with:
clean: false
apple_team_id: ${{ steps.resolve_apple_team_id_from_credentials.outputs.apple_team_id }}
属性 | 类型 | 描述 |
---|---|---|
clean | boolean | 可选属性定义函数在运行命令时是否应使用 --clean 标志。默认为 false。 |
apple_team_id | string | 可选属性定义在进行预构建时应使用的 Apple 团队 ID。应使用凭据为 iOS 构建指定它。 |
在 GitHub 上查看 eas/prebuild 函数的源代码。
eas/send_slack_message
将指定的消息发送到配置的 Slack Webhook URL,然后将其发布到相关的 Slack 通道中。消息可以指定为纯文本或 Slack 块套件 消息。对于这两种情况,你都可以在消息中引用构建作业属性和 使用其他步骤输出 以进行动态评估。例如,Build URL: ${ eas.job.expoBuildUrl }
、Build finished with status: ${ steps.run_fastlane.status_text }
、Build failed with error: ${ steps.run_gradle.error_text }
。必须指定 "message" 或 "payload",但不能同时指定两者。
¥Sends a specified message to a configured Slack webhook URL, which then posts it in the related Slack channel. The message can be specified as plaintext or as a Slack Block Kit message.
With both cases, you can reference build job properties and use other steps outputs in the message for dynamic evaluation. For example, Build URL: ${ eas.job.expoBuildUrl }
, Build finished with status: ${ steps.run_fastlane.status_text }
, Build failed with error: ${ steps.run_gradle.error_text }
.
Either "message" or "payload" has to be specified, but not both.
jobs:
my_job:
steps:
- uses: eas/send_slack_message
with:
message: 'This is a message to plain input URL'
slack_hook_url: 'https://hooks.slack.com/services/[rest_of_hook_url]'
属性 | 类型 | 描述 |
---|---|---|
message | string | 你要发送的消息的文本。例如 'This is the content of the message' .注:需要提供 message 或 payload 之一,但不能同时提供两者。 |
payload | json | 要发送的消息内容,使用 Slack 块套件 布局定义。 注意:需要提供 message 或 payload 之一,但不能同时提供两者。 |
slack_hook_url | string | 之前配置的 Slack webhook URL,它将把你的消息发布到指定的通道。你可以提供纯文本 URL(如 slack_hook_url: 'https://hooks.slack.com/services/[rest_of_hook_url]' ),使用 EAS 密钥(如 slack_hook_url: ${{ env.ANOTHER_SLACK_HOOK_URL }} ),或设置 SLACK_HOOK_URL 密钥,它将用作默认 webhook URL(在最后一种情况下,无需提供 slack_hook_url 属性)。 |
在 GitHub 上查看 eas/send_slack_message 函数的源代码。
eas/use_npm_token
配置 Node 包管理器(bun、npm、pnpm 或 Yarn)以用于私有包,发布到 npm 或私有注册表。
¥Configures Node package managers (bun, npm, pnpm, or Yarn) for use with private packages, published either to npm or a private registry.
在项目的密钥中设置 NPM_TOKEN
,此函数将通过使用令牌创建 .npmrc 来配置构建环境。
¥Set NPM_TOKEN
in your project's secrets, and this function will configure the build environment by creating .npmrc with the token.
jobs:
my_job:
name: Install private npm modules
steps:
- uses: eas/checkout
- uses: eas/use_npm_token
- name: Install dependencies
run: npm install # <---- Can now install private packages
在 GitHub 上查看 eas/use_npm_token 函数的源代码。