BobbyP
BobbyP

Reputation: 2255

Github workflow triggering on source branch of pull request

I have two branches, staging and main. I also have two workflows, again named staging and main

Staging Workflow

name: SSH Deployment to Staging

on:
  push:
    branches: [staging]
  pull_request:
    branches: [staging]

jobs:
  deploy_to_staging:

Production Workflos

name: SSH Deployment to Production

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  deploy_to_main:
    name: Deploy to Production

The idea is that I develop on the staging branch and when I push to github, the staging workflow triggers. Then, when I am happy, I create a pull request and merge the staging branch into the main branch. At that point, I expect the main workflow to run.

This does all happen. However, when I merge the staging branch into main, as well as the main workflow triggering, the staging workflow triggers again as well.

Is there a way I can update the main workflow so it runs only when it is the target branch of a pull request and not the source branch? I know there are types attributes, but not sure which - if any - will do what I need.

Upvotes: 0

Views: 22

Answers (0)

Related Questions