'Trigger an action on push or pull request but not both

I have this workflow : (not complet)

# Only one deploy/publish can run
concurrency:
  group: lydie-front-deploy
  cancel-in-progress: true

on:  

  pull_request:
    branches:
      - dev
    types:
      - closed
  push:
    branches:
      - dev
  jobs:
      build:
        runs-on: ubuntu-latest
        if: github.event.pull_request.merged || github.event_name == 'push'

Problem : when I valid a pull_request, and merge it, the push event come just after and I have two actions running.

If there a way to run my workflow if I had a pull_request (merged) or a push but not both? I've checked the concurrency option but it's not what I need : I don't want to cancel a previous jobs.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source