This article demonstrates how to clone a Git repository within GitHub Actions workflows, providing detailed instructions for various scenarios. It addresses the ability to clone a specific repository, fetch a different one, or access separate reposit
要将存储库克隆到 GitHub Action 工作流程中,您可以使用 actions/checkout
操作。此操作会将 repo
输入中指定的存储库克隆到当前工作目录。
例如,以下工作流程会将 my-repo
存储库克隆到当前工作目录:
name: Clone repository on: push jobs: clone-repo: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: repo: my-repo
是的,有一种方法可以在 GitHub Actions 中获取不同的存储库。您可以使用 actions/fetch
操作将存储库提取到当前工作目录中。
例如,以下工作流程会将 my-repo
存储库提取到当前工作目录中:
name: Fetch repository on: push jobs: fetch-repo: runs-on: ubuntu-latest steps: - uses: actions/fetch@v2 with: repo: my-repo
要访问 GitHub Actions 工作流程中的单独存储库,您可以使用 multi-repo
功能。此功能允许您在单个工作流文件中定义多个存储库。
例如,以下工作流将定义两个存储库 my-repo
和 my-other-repo
,并将在这两个存储库上运行作业:
name: Multi-repo workflow on: push jobs: clone-repo: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: repo: my-repo clone-other-repo: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: repo: my-other-repo
以上是如何在 github actions 中签出另一个仓库的详细内容。更多信息请关注PHP中文网其他相关文章!