{"meta":{"title":"补充参数和设置","intro":"GitHub Actions Importer 有多个补充参数和设置，可根据需要定制迁移过程。","product":"GitHub Actions","breadcrumbs":[{"href":"/zh/actions","title":"GitHub Actions"},{"href":"/zh/actions/reference","title":"参考"},{"href":"/zh/actions/reference/github-actions-importer","title":"GitHub Actions 导入工具"},{"href":"/zh/actions/reference/github-actions-importer/supplemental-arguments-and-settings","title":"补充参数和设置"}],"documentType":"article"},"body":"# 补充参数和设置\n\nGitHub Actions Importer 有多个补充参数和设置，可根据需要定制迁移过程。\n\n本文提供有关配置 GitHub Actions Importer 的补充参数和设置（例如可选参数、路径参数和网络设置）的一般信息。\n\n## 可选参数\n\nGitHub Actions Importer 有多个可选参数，可用于自定义迁移过程。\n\n### 限制允许的操作\n\n以下选项可用于限制转换工作流中允许的操作。 当组合使用时，这些选项扩大了允许的操作列表。 如果没有提供这些选项，则允许所有操作。\n\n* `--allowed-actions` 指定要在转换后的工作流中允许的操作的列表。 支持通配符。 除已提供的操作外，其他任何操作都将被禁止。\n\n  例如：\n\n  ```shell\n  --allowed-actions actions/checkout@v6 actions/upload-artifact@* my-org/*\n  ```\n\n  可以提供一个空列表来禁止所有操作。 例如，`--allowed-actions=`。\n\n* `--allow-verified-actions` 指定允许来自已验证创建者的所有操作。\n\n* `--allow-github-created-actions` 指定允许从 `github` 或 `actions` 组织发布的操作。\n\n  例如，此类操作包括 `github/super-linter` 和 `actions/checkout`。\n\n  此选项等同于 `--allowed-actions actions/* github/*` 命令。\n\n### 使用凭据文件进行身份验证\n\n              `--credentials-file` 参数指定一个文件的路径，该文件包含不同服务器的凭据，GitHub Actions Importer 可以用来进行身份验证。 当生成脚本（如 `.travis.yml` 或 `jenkinsfile`）存储在多个 GitHub Enterprise Server 实例中时，这非常有用。\n\n凭据文件必须是包含服务器和访问令牌组合的列表的 YAML 文件。 GitHub Actions Importer 使用与发出的网络请求最匹配的 URL 的凭据。\n\n例如：\n\n```yaml\n- url: https://github.com\n  access_token: ghp_mygeneraltoken\n- url: https://github.com/specific_org/\n  access_token: ghp_myorgspecifictoken\n- url: https://jenkins.org\n  access_token: abc123\n  username: marty_mcfly\n```\n\n对于上述凭据文件，GitHub Actions Importer 使用访问令牌 `ghp_mygeneraltoken` 对向 `https://github.com` 发出的所有网络请求进行身份验证，除非网络请求是面向 __ 组织中的存储库。 在这种情况下，`ghp_myorgspecifictoken` 令牌用于进行身份验证。\n\n#### 替代源代码提供程序\n\nGitHub Actions Importer 可以从非 GitHub 存储库自动提取源代码。 凭据文件可以指定 `provider`、提供程序 URL 以及检索源代码所需的凭据。\n\n例如：\n\n```yaml\n- url: https://gitlab.com\n  access_token: super_secret_token\n  provider: gitlab\n```\n\n对于上述示例，GitHub Actions Importer 使用令牌 `super_secret_token` 检索托管在 `https://gitlab.com` 上的任何源代码。\n\n              `provider` 支持的值有：\n\n* `github`（默认值）\n* `gitlab`\n* `bitbucket_server`\n* `azure_devops`\n\n### 控制可选功能\n\n可以使用 `--features` 选项来限制 GitHub Actions Importer 创建的工作流中使用的功能。 这可用于在迁移到较旧的 GitHub Actions 实例时，从工作流中排除较新的 GitHub Enterprise Server 语法。 使用 `--features` 选项时，必须指定要迁移到的 GitHub Enterprise Server 的版本。\n\n例如：\n\n```shell\ngh actions-importer dry-run ... --features ghes-3.3\n```\n\n              `--features` 支持的值如下：\n\n* `all`（默认值）\n* `ghes-latest`\n* `ghes-<number>`，其中 `<number>` 是 GitHub Enterprise Server 的版本（`3.0` 或更高版本）。 例如，`ghes-3.3`。\n\n可以通过运行 `list-features` 命令，通过 GitHub Actions Importer 查看可用的特性标志列表。 例如：\n\n```shell copy\ngh actions-importer list-features\n```\n\n此时会看到类似下面的输出。\n\n<!-- markdownlint-disable search-replace -->\n\n```shell\nAvailable feature flags:\n\nactions/cache (disabled):\n        Control usage of actions/cache inside of workflows. Outputs a comment if not enabled.\n        GitHub Enterprise Server >= ghes-3.5 required.\n\ncomposite-actions (enabled):\n        Minimizes resulting workflow complexity through the use of composite actions. See https://docs.github.com/en/actions/creating-actions/creating-a-composite-action for more information.\n        GitHub Enterprise Server >= ghes-3.4 required.\n\nreusable-workflows (disabled):\n        Avoid duplication by re-using existing workflows. See https://docs.github.com/en/actions/using-workflows/reusing-workflows for more information.\n        GitHub Enterprise Server >= ghes-3.4 required.\n\nworkflow-concurrency-option-allowed (enabled):\n        Allows the use of the `concurrency` option in workflows. See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency for more information.\n        GitHub Enterprise Server >= ghes-3.2 required.\n\nEnable features by passing --enable-features feature-1 feature-2\nDisable features by passing --disable-features feature-1 feature-2\n```\n\n<!-- markdownlint-enable search-replace -->\n\n若要切换功能标志，可以使用以下任一方法：\n* 运行 `--enable-features` 命令时使用 `--disable-features` 和 `gh actions-importer` 选项。\n* 为每个功能标志使用环境变量。\n\n可以使用 `--enable-features` 和 `--disable-features` 选项选择要在命令执行期间启用或禁用的特定功能。\n例如，以下命令禁用 `actions/cache` 和 `composite-actions`：\n\n```shell\ngh actions-importer dry-run ... --disable-features=composite-actions actions/cache\n```\n\n可以使用 `configure --features` 命令以交互方式配置功能标志，并自动将其写入环境：\n\n```shell\n$ gh actions-importer configure --features\n\n✔ Which features would you like to configure?: actions/cache, reusable-workflows\n✔ actions/cache (disabled): Enable\n? reusable-workflows (disabled):\n› Enable\n  Disable\n```\n\n### 禁用网络响应缓存\n\n默认情况下，GitHub Actions Importer 会缓存来自网络请求的响应，以减少网络负载并减少运行时。 可以使用 `--no-http-cache` 选项来禁用网络缓存。 例如：\n\n```shell\ngh actions-importer forecast ... --no-http-cache\n```\n\n## 路径参数\n\n运行 GitHub Actions Importer 时，路径参数与容器的磁盘相关，因此相对于容器的主机的绝对路径不受支持。 运行 GitHub Actions Importer 时，容器的 `/data` 目录会装载到运行 GitHub Actions Importer 的目录。\n\n例如，以下命令（在 `/Users/mona` 目录中使用时）将 GitHub Actions Importer 审核摘要输出到 `/Users/mona/out` 目录：\n\n```shell\ngh actions-importer audit --output-dir /data/out\n```\n\n## 使用代理\n\n若要访问配置了 HTTP 代理的服务器，必须使用代理的 URL 设置以下环境变量：\n\n* `OCTOKIT_PROXY`：适用于任何 GitHub 服务器。\n* `HTTP_PROXY`（或 `HTTPS_PROXY`）：适用于任何其他服务器。\n\n例如：\n\n```shell\nexport OCTOKIT_PROXY=https://proxy.example.com:8443\nexport HTTPS_PROXY=$OCTOKIT_PROXY\n```\n\n如果代理需要身份验证，必须在代理 URL 中包含用户名和密码。 例如，`https://username:password@proxy.url:port`。\n\n## 禁用 SSL 证书验证\n\n默认情况下，在发出网络请求时，GitHub Actions Importer 会验证 SSL 证书。 可以使用 `--no-ssl-verify` 选项禁用 SSL 证书验证。 例如：\n\n```shell\ngh actions-importer audit --output-dir ./output --no-ssl-verify\n```\n\n## 法律通告\n\n部分内容改编自 MIT 许可证下的 https://github.com/github/gh-actions-importer/ ：\n\n```text\nMIT License\n\nCopyright (c) 2022 GitHub\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```"}