Deployment event raised on commits to main

Hi

Looking for some assistance on understanding the deployment event. My understanding was that this event should only be raised when a new deployment is created using the Deployment API? However, I’m observing it being raised whenever we push a new commit to our main branch as well, for the same environment that our second workflow is targeting.

For example, if I have something like this

on:
  push:
    branches:
      - main
    tags-ignore:
      - '**'

name: on-commit-to-main

jobs:
  Verify:
    environment: stage
    runs-on: ubuntu-latest
    steps:
       .....

and also this

on:
  deployment

name: on-deployment

jobs:
  Verify:
    environment: ${{ github.event.deployment.environment }}
    runs-on: ubuntu-latest
    steps:
       ....

then the on-deployment workflow is also triggered as soon as a new commit is made towards main. I’ve not found any documentation (for example Events that trigger workflows - GitHub Docs or Repositories - GitHub Docs)

We definitely don’t want the on-deployment workflow to trigger like that, but rather only when creating a deployment using the API

One thing I’ve noticed is that for the automatically generated triggers, the workflow and workflow_run properties on github.event is set. For example github.event.workflow.name will be set to on-commit-to-main

I know I could add

if: github.event.workflow == null

On the job in my on-deployment workflow, but it would still be raised just end up as skipped. I’d like for the automatically raised event never to be raised in the first place.

Thanks!