Home > Mobile >  Combine multiple triggers with multiple branches
Combine multiple triggers with multiple branches

Time:02-08

How can we run github workflows on multiple branches for multiple triggers? Example - How can I run a workflow on pull_request & push on say prod & dev? Refer the code snippet below

on: [push, pull_request]
  branches:    
    - 'dev'
    - 'prod'

The above isn't allowed. I get the following error -

Property branches is not allowed.yaml-schema: GitHub Workflow

How can I handle this?

CodePudding user response:

You can have multiple events triggering your workflow with subtypes.

Therefore, to achieve what you want (run a workflow on pull_request & push on prod & dev), you would need this implementation:

on:
  push:
    branches:    
      - 'dev'
      - 'prod'

  pull_request:
    branches:    
      - 'dev'
      - 'prod'

The problem in your implementation was that the branches isn't a on subtype in github actions, it's only a pull_request or push subtype.

  •  Tags:  
  • Related