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?

1 answer

  • answered 2022-05-04 22:05 timmeinerzhagen

    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?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum