1

I'm having difficulties figuring out the syntax for triggering off of different event types.

For example the following gives me a "duplicated mapping key" error on the secod pull_request trigger.

on:

  pull_request:
    types: [opened, reopened]
    branches:
      - main
      - develop
      
  pull_request:
    types [synchronize]
    branches:
      - main
      - develop
    paths: ['**.h', '**.cpp', '**.hpp', '**.yaml', '**CMakeLists.txt', '**Makefile', '**.spec', '**.py', '**Dockerfile', '**conanfile.txt']

I want the workflow to always run when first opened (or reopened) but subsequently when the branch is synchronized it should only run if the changes are in one of the specified file types.

To clarify, I already have on.push event hook that's not shown here for the sake of brevity.

I do believe I neeed to have a pull_request.synchronize event to handle updated.

Can't find anything in the documentation on how to do that. I tried combining the two pull_requests triggers but then I'm getting an error that the "types" key is being duplicated.

Any ideas?

ventsyv
  • 3,316
  • 3
  • 27
  • 49

1 Answers1

0

The documentation does talk about triggering based on multiple events, but not multiple events of the same type, so it isn't entirely clear if this is possible (beyond the validation errors).

To make this work you need to define three different workflows, one with each varying type of event and its filters and another with the reusable workflow using a workflow_call event.

#workflow-1
on:
  pull_request:
    types: [opened, reopened]
    branches:
      - main
      - develop

jobs:
  job:
    uses: ./.github/workflows/workflow-3.yml
#workflow-2
on:
  pull_request:
    types: [synchronize]
    branches:
      - main
      - develop
    paths: ['**.h', '**.cpp', '**.hpp', '**.yaml', '**CMakeLists.txt', '**Makefile', '**.spec', '**.py', '**Dockerfile', '**conanfile.txt']

jobs:
  job:
    uses: ./.github/workflows/workflow-3.yml
#workflow-3
on:
  workflow_call:

jobs:
  job:
    steps:
      - run: do stuff
aknosis
  • 3,602
  • 20
  • 33