talhaamir
talhaamir

Reputation: 129

How to run multiple GitHub Actions workflows from sub directories

I have 3 directories in ./github/workflows/

In each of these directories I have multiple workflow .yml files for example in linters/codeQuality.yml

My issue is that when a pull request is made then only the workflows files in root are executed and not the workflow files in these diretories.

How can I solve this problem?

Upvotes: 4

Views: 7820

Answers (1)

riQQ
riQQ

Reputation: 12693

You can't run workflows from subdirectories:

You must store workflow files in the .github/workflows directory of your repository.

Source: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#about-yaml-syntax-for-workflows


You can however use composite run steps actions (documentation).

.github/workflows/workflow.yaml

[...]

jobs:
  myJob:
    name: My Job
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - uses: ./.github/workflows/linters/codeQuality

[...]

.github/workflows/linters/codeQuality/action.yaml

name: "My composite action"
description: "Checks out the repository and does something"
runs:
  using: "composite"
  steps: 
  - run: |
      echo "Doing something"

  [other steps...]

Upvotes: 10

Related Questions