This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

使用 EAS 工作流清理 EAS 更新分支

了解如何在删除 GitHub 分支时使用 EAS 工作流删除 EAS 更新分支。


你可能会发布 EAS Update 分支的更新,这些分支以 GitHub 分支命名,例如使用 eas update --auto、带有 branch: ${{ github.ref_name }}update 工作流作业,或在每个分支上预览更新。当你这样做时,删除 GitHub 分支会留下 EAS Update 分支。此工作流在删除 Git 分支时会清理孤立的 EAS Update 分支。

🌐 You might publish updates to EAS Update branches named after GitHub branches, for example with eas update --auto, the update workflow job with branch: ${{ github.ref_name }}, or preview updates on every branch. When you do, deleting the GitHub branch leaves the EAS Update branch behind. This workflow cleans up the orphaned EAS Update branch when a Git branch is deleted.

开始使用

🌐 Get started

先决条件

3 要求

1.

设置 EAS 更新

你的项目需要配置EAS 更新。你可以通过以下方式设置你的项目:

Terminal
eas update:configure

2.

连接你的 GitHub 仓库

你的 EAS 项目必须链接到一个 GitHub 仓库。请参阅 开始使用 EAS 工作流

3.

默认分支上的工作流文件

请将此工作流文件保存在仓库的默认分支上。当分支被删除时,EAS 会从默认分支的 HEAD 而不是已删除的引用中读取工作流配置。

以下工作流程会删除与已删除的 GitHub 分支同名的 EAS Update 分支:

🌐 The following workflow deletes the EAS Update branch with the same name as the deleted GitHub branch:

.eas/workflows/branch-cleanup.yml
name: Branch cleanup on: ref_delete: branches: ['*', '!main'] jobs: delete-update-branch: type: branch-delete params: branch_name: ${{ github.ref_name }}

工作原理

🌐 How it works

  1. on.ref_delete 会在删除符合模式的 GitHub 分支时运行。上面的示例会在除了 main 之外的所有分支上触发。
  2. branch-delete 作业会删除名为 ${{ github.ref_name }} 的 EAS 更新分支,该名称与已删除的 Git 分支相同。
  3. 使用默认的 fail_on_missing: false,即使 EAS 更新分支已被删除或从未存在,作业也会成功。

重要说明

🌐 Important notes

  • github.sha 是默认分支,而不是已删除引用的最后一次提交。有关 ref_delete 运行的插值详细信息,请参见 github 上下文参考
  • 通道映射阻止删除:如果一个通道指向 EAS 更新分支,删除将因通道映射相关错误而失败。
  • 使用诸如 !main!release/** 的否定模式在 on.ref_delete.branches 中保护你不希望被清理的分支。