从父回购操作触发子模块中的 GitHub 操作
Trigger GitHub Action in Submodules from Parent Repo Action
假设我有两个存储库,parentrepo 和 childrepo。
childrepo 有一个 github 操作(来自 docs 的示例):
name: GitHub Actions Demo
on: workflow_dispatch
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo " The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo " This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo " The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo " The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo " This job's status is ${{ job.status }}."
我添加了 childrepo 存储库作为 parentrepo 存储库的子模块。
现在从 parentrepo 中的 GitHub 操作我想在 childrepo 子模块中触发作业:
name: build
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Build
uses: ./childrepo/.github/workflows/action.yml
但失败并出现错误:
Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under
'/home/runner/work/parentrepo/parentrepo/childrepo/.github/workflows'.
Did you forget to run actions/checkout before running your local
action?
我该怎么做?
uses
关键字不用于在另一个存储库中启动操作 运行。它只能从另一个存储库中获取一个动作或可重用的工作流并将其用于自己。
没有这方面的本机功能。然而,可以通过 API 在另一个存储库中调度工作流 运行。参见
假设我有两个存储库,parentrepo 和 childrepo。 childrepo 有一个 github 操作(来自 docs 的示例):
name: GitHub Actions Demo
on: workflow_dispatch
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo " The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo " This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo " The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo " The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo " This job's status is ${{ job.status }}."
我添加了 childrepo 存储库作为 parentrepo 存储库的子模块。 现在从 parentrepo 中的 GitHub 操作我想在 childrepo 子模块中触发作业:
name: build
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Build
uses: ./childrepo/.github/workflows/action.yml
但失败并出现错误:
Error: Can't find 'action.yml', 'action.yaml' or 'Dockerfile' under '/home/runner/work/parentrepo/parentrepo/childrepo/.github/workflows'. Did you forget to run actions/checkout before running your local action?
我该怎么做?
uses
关键字不用于在另一个存储库中启动操作 运行。它只能从另一个存储库中获取一个动作或可重用的工作流并将其用于自己。
没有这方面的本机功能。然而,可以通过 API 在另一个存储库中调度工作流 运行。参见