import-into

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Import Into

导入到现有清单

Use this skill for
gh infra import --into=...
.
This workflow is different from normal
import
,
plan
, and
apply
:
  • it updates local manifests from live GitHub state
  • it may rewrite YAML, local source files, or manifest patches
  • it has file-level write modes and skip safety rules
该技能用于
gh infra import --into=...
命令。
该工作流与常规的
import
plan
apply
不同:
  • 它会根据GitHub实时状态更新本地清单
  • 可能会重写YAML、本地源文件或清单补丁
  • 具备文件级写入模式和跳过安全规则

When To Use

使用场景

Use this skill when the user wants to:
  • pull GitHub state back into existing manifests
  • reconcile drift from GitHub UI into local YAML
  • decide between
    write
    ,
    patch
    , and
    skip
  • understand why a file was skipped during import
  • update shared templates safely after repository-side drift
当用户需要执行以下操作时可使用该技能:
  • 将GitHub状态拉取回现有清单
  • 同步GitHub UI上的变更漂移到本地YAML
  • write
    patch
    skip
    模式之间做决策
  • 理解导入过程中文件被跳过的原因
  • 仓库侧出现配置漂移后安全更新共享模板

Command

命令

bash
gh infra import <owner/repo> [owner/repo ...] --into=<path>
<path>
may be a file or a directory of manifests.
bash
gh infra import <owner/repo> [owner/repo ...] --into=<path>
<path>
可以是单个文件,也可以是存放清单的目录。

How It Works

工作原理

  1. Parse local manifests
  2. Match target repositories against
    Repository
    ,
    RepositorySet
    , and
    FileSet
  3. Fetch live state from GitHub
  4. Diff local vs remote
  5. Show plan output
  6. For file changes, open the interactive diff viewer
  7. Write approved local changes
  1. 解析本地清单
  2. 将目标仓库与
    Repository
    RepositorySet
    FileSet
    规则匹配
  3. 从GitHub拉取实时状态
  4. 对比本地与远程配置的差异
  5. 输出执行计划
  6. 针对文件变更,打开交互式差异查看器
  7. 写入审批通过的本地变更

File Write Modes

文件写入模式

  • write
    : update the normal local target
  • patch
    : store the drift under
    patches:
  • skip
    : ignore for this run
Typical defaults:
  • inline content:
    write
  • single-use local source:
    write
  • shared local source:
    patch
  • existing
    patches:
    entry:
    patch
  • many
    create_only
    entries:
    skip
  • write
    :更新常规本地目标文件
  • patch
    :将漂移配置存储在
    patches:
    字段下
  • skip
    :本次运行忽略该变更
典型默认规则:
  • 内联内容:
    write
  • 单次使用的本地源:
    write
  • 共享本地源:
    patch
  • 已有
    patches:
    条目:
    patch
  • 大量
    create_only
    条目:
    skip

Safety Rules

安全规则

There are two skip modes:
  • default skip: safe enough to import, but skipped by default
  • hard skip: cannot be written back safely
Hard-skip cases include:
  • github://
    sources
  • template-backed files whose placeholders cannot be reverse-mapped safely
存在两种跳过模式:
  • 默认跳过:足够安全可以导入,但默认被跳过
  • 强制跳过:无法安全回写
强制跳过的场景包括:
  • github://
    源文件
  • 占位符无法安全反向映射的模板支撑文件

Template-Backed Files

模板支撑文件

For templates such as
<% .Repo.Name %>
and
<% .Repo.FullName %>
, gh-infra compares:
  1. rendered local template
  2. remote GitHub file
It then tries to reconstruct updated local template source while preserving placeholders.
Use
write
only when you want to update the underlying shared source. Use
patch
when drift should stay repository-specific.
对于包含
<% .Repo.Name %>
<% .Repo.FullName %>
这类变量的模板,gh-infra会对比:
  1. 渲染后的本地模板
  2. 远程GitHub文件
随后会尝试重建更新后的本地模板源,同时保留占位符。
仅当你需要更新底层共享源时使用
write
模式;当漂移配置需要保留为仓库专属配置时使用
patch
模式。

What Gets Updated

可更新内容

  • repository settings: patched into YAML
  • inline file content: written back into the manifest
  • local
    source: ./...
    files: written back to the source file
  • shared local source files: often better stored as patches
  • 仓库设置:作为补丁写入YAML
  • 内联文件内容:回写到清单中
  • 本地
    source: ./...
    文件:回写到源文件
  • 共享本地源文件:通常更适合存储为补丁

What Does Not Get Imported

无法导入内容

  • secrets: GitHub does not return secret values
  • github://
    sources: no local write target
  • template-backed files that cannot be reverse-mapped safely
  • 密钥:GitHub不会返回密钥值
  • github://
    源文件:无本地写入目标
  • 无法安全反向映射的模板支撑文件

Read Next

后续阅读

  • Examples and detailed behavior: references/behavior.md
  • Diff-viewer decisions: references/write-modes.md
  • Template safety: references/template-safety.md
  • 示例与详细行为:references/behavior.md
  • 差异查看器决策规则:references/write-modes.md
  • 模板安全:references/template-safety.md