{"meta":{"title":"自定义 GitHub 托管的运行器","intro":"可以将其他软件作为工作流的一部分安装在GitHub托管的运行程序上。","product":"GitHub Actions","breadcrumbs":[{"href":"/zh/actions","title":"GitHub Actions"},{"href":"/zh/actions/how-tos","title":"操作方法"},{"href":"/zh/actions/how-tos/manage-runners","title":"管理运行器"},{"href":"/zh/actions/how-tos/manage-runners/github-hosted-runners","title":"GitHub 托管的运行程序"},{"href":"/zh/actions/how-tos/manage-runners/github-hosted-runners/customize-runners","title":"自定义运行器"}],"documentType":"article"},"body":"# 自定义 GitHub 托管的运行器\n\n可以将其他软件作为工作流的一部分安装在GitHub托管的运行程序上。\n\n如果您需要在 GitHub 托管的运行器上使用其他软件包，则可以创建一个作业，在工作流中安装这些软件包。\n\n若要查看默认已安装的包，请参阅“[GitHub 托管的运行程序](/zh/actions/concepts/runners/github-hosted-runners#preinstalled-software-for-github-owned-images)”。\n\n本指南演示如何创建一个作业，以便在 GitHub 托管的运行器上安装额外软件。\n\n## 在 Ubuntu 运行器上安装软件\n\n以下示例演示如何在作业中安装 `apt` 包。\n\n```yaml\nname: Build on Ubuntu\non: push\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Check out repository code\n        uses: actions/checkout@v6\n      - name: Install jq tool\n        run: |\n          sudo apt-get update\n          sudo apt-get install jq\n```\n\n> \\[!NOTE]\n> 安装包之前始终运行 `sudo apt-get update`。 如果 `apt` 索引已经过时，此命令将获取并重新索引任何可用的包，这有助于防止包安装失败。\n\n## 在 macOS 运行器上安装软件\n\n以下示例演示如何将 Brew 包和桶安装为作业的一部分。\n\n```yaml\nname: Build on macOS\non: push\n\njobs:\n  build:\n    runs-on: macos-latest\n    steps:\n      - name: Check out repository code\n        uses: actions/checkout@v6\n      - name: Install GitHub CLI\n        run: |\n          brew update\n          brew install gh\n      - name: Install Microsoft Edge\n        run: |\n          brew update\n          brew install --cask microsoft-edge\n```\n\n## 在Windows运行器上安装软件\n\n以下示例演示如何使用 [Chocolatey](https://community.chocolatey.org/packages) 在任务中安装 GitHub CLI。\n\n```yaml\nname: Build on Windows\non: push\njobs:\n  build:\n    runs-on: windows-latest\n    steps:\n      - run: choco install gh\n      - run: gh version\n```"}