7

I have a Github Actions workflow that fires on:

on:
  pull_request:
    types:
      - synchronize
      - opened

that runs my custom action:

jobs:
  my_job:
    uses: "org/repo/.github/workflows/main.yml@master"

In the action org/repo I want to do an additional thing when a pull request is opened, but not when it is synchronized. So in org/repo/.github/workflows/main.yml I do:

- if: ${{ condition }}
  name: Do that additional thing

What should be the condition to differentiate between a newly open pull request event and a "synchronize" event (pushing new commits etc)? I guess that would involve checking something in ${{ github.event.pull_request }}, but I couldn't find it in the documentation.

gvlasov
  • 18,638
  • 21
  • 74
  • 110

1 Answers1

11

The condition is:

- if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
gvlasov
  • 18,638
  • 21
  • 74
  • 110