'Trigger GitHub Action in Submodules from Parent Repo Action
Let's say that I have two repositories, parentrepo and childrepo. childrepo has a github action (example from the 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 }}."
I added childrepo repository as a submodule of the parentrepo repository. Now from the GitHub Action in the parentrepo I want to trigger job in childrepo submodule:
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
but it's failing with error:
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?
How can I do it?
Solution 1:[1]
The uses keyword is not intended to start an Actions run in another repository. It can only fetch an action or reusable workflow from another repo and use it for itself.
There is no native functionality for this. Dispatching a workflow run in another repository is however possible via the API. See How to trigger a workflow_dispatch from Github API?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | timmeinerzhagen |
