Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 3
Message 1 of 3

Finding the event that triggered an action

Hi there, I would like to build a GitHub app that automatically marks deployment statuses based on the status of an action.

Say I have the below workflow file, if this is running a deployment I have to manually mark the deployment status as 'pending' and then when it's finished, or failed, I have to have a step to mark the corresponding deployment with that status as well. I want to remove those extra steps from my workflow file.


What I think I can do here is listen for the check_run event and find out if this check run was triggered by a deployment. If it is, I should be able to add deployment_status events to the corresponding deployment for the action. What's missing: Finding the event that triggered the check_run / action run. I don't believe I can do this right now.

 

Anyone have any ideas? Much appreciated!

 

 

  
name: 'Deploy'
on: ['deployment']

jobs:
  deployment:
    runs-on: 'ubuntu-latest'
    steps:
    - name: 'Checkout'
      uses: 'actions/checkout@v1'

    - name: 'Deployment pending'
      uses: 'deliverybot/deployment-status@master'
      with:
        state: 'pending'
        token: '${{ github.token }}'

    - name: 'Deploy ${{ github.event.deployment.environment }}'
      run: 'echo "do deploy..."'
- name: 'Deployment success' if: success() uses: 'deliverybot/deployment-status@master' with: state: 'success' token: '${{ github.token }}' - name: 'Deployment failure' if: failure() uses: 'deliverybot/deployment-status@master' with: state: 'failure' token: '${{ github.token }}'

 

2 Replies
Pilot Lvl 1
Message 2 of 3

Re: Finding the event that triggered an action


@colinjfw wrote:

What's missing: Finding the event that triggered the check_run / action run. I don't believe I can do this right now.

 

You can. It's a default environment variable named GITHUB_EVENT_NAME. So you can use it anywhere in your workflow if you want to verify how it was triggered.

Highlighted
Copilot Lvl 3
Message 3 of 3

Re: Finding the event that triggered an action

I should have specified this, I'm looking to do this outside of a GitHub action, specifically in a probot application. Ideally I can listen to some sort of event that gives me the information that 1) This github action was completed with status "success" and 2) this is the event that triggered it.

I mention specifically the check_run event since that's (right now) what an action fires after it's finished.