Skip to content

How to run a workflow only once, even when triggered mutliple times #26741

Answered by oldskool
a-recknagel asked this question in Actions
Discussion options

You must be logged in to vote

In order to trigger things when they are merged into master, you can use the following workflow structure:

on:
  pull_request:
    types: [closed]
    branches:
      - master

jobs:
deploy:
runs-on: ubuntu-latest

steps:
  - name: checkout
    if: github.event.pull_request.merged
    uses: actions/checkout@v1
    with:
      ref: master

Note the “if” condition on the step. You will need to add that to every step to make sure it only run whenever the PR was actually merged (and not closed/discarded without merge). There is currently no way to enforce such a condition on all steps in a job yet, but this setup works just fine for my CD workflow (which I also only want to trigger when someth…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants