Githubアクションで別のリポジトリをチェックアウトする方法

Barbara Streisand
リリース: 2024-10-10 11:22:19
オリジナル
903 人が閲覧しました

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アクションで別のリポジトリをチェックアウトする方法

How can I clone a repository into a GitHub Action workflow?

To clone a repository into a GitHub Action workflow, you can use the actions/checkout action. This action will clone the repository specified in the repo input into the current working directory.

For example, the following workflow will clone the my-repo repository into the current working directory:

<code class="yaml">name: Clone repository
on: push

jobs:
  clone-repo:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          repo: my-repo</code>
ログイン後にコピー

Is there a method to fetch a different repository in GitHub Actions?

Yes, there is a method to fetch a different repository in GitHub Actions. You can use the actions/fetch action to fetch a repository into the current working directory.

For example, the following workflow will fetch the my-repo repository into the current working directory:

<code class="yaml">name: Fetch repository
on: push

jobs:
  fetch-repo:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/fetch@v2
        with:
          repo: my-repo</code>
ログイン後にコピー

How do I access separate repositories within a GitHub Actions workflow?

To access separate repositories within a GitHub Actions workflow, you can use the multi-repo feature. This feature allows you to define multiple repositories in a single workflow file.

For example, the following workflow will define two repositories, my-repo and my-other-repo, and will run jobs on both repositories:

<code class="yaml">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</code>
ログイン後にコピー

以上がGithubアクションで別のリポジトリをチェックアウトする方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
著者別の最新記事
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!