Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to trigger Github Workflow after a check suite finishes?

I want to trigger a workflow only if a particular workflow finishes... does anyone know how to do that?

Some context:

  • I have a workflow Tests and another called Build-feature.
  • I run my Tests workflow on every PR to branch feature.
  • If something is pushed/merged to branch feature then i want to run workflow Tests and only if that succeeds then i want to run Build-feature workflow.

Also there's the event check_suite that it's supposed to trigger a workflow: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows#check-suite-event-check_suite

I tried this example:

on:
  check_suite:
    types: [rerequested, completed]

But my workflow never triggers, any ideas why? or any other idea on how can i achieve the above?.

like image 624
Xotl Avatar asked Oct 20 '25 21:10

Xotl


1 Answers

Updated answer:

Turns out that you can achieve that using the on: status event, but you need to manually trigger the status with a token that is not the one from the Github Actions.

You need to add something like this in order to trigger the status event after a workflow finishes:

      - name: Trigger status event
        run: >-
          curl -L -X POST 
          -H "Content-Type: application/json"
          -H "Authorization: token ${{ secrets.GITHUB_PAT}}"
          -d '{
            "state": "success",
            "target_url": "https://you-can-add-a.url/",
            "description": "All tests passed", "context": "your-custom/status-event"
          }'
          "https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA}"

And in your other workflow you can just add an if condition in case you have more than one status event that can trigger the workflow, something like this:

on: status

...

jobs:

...

  if: github.event.context == 'your-custom/status-event'

And that's it... That's how you can chain workflows.



Old answer:

Well, after asking at the github.community forum i got an answer.

Events raised from the Actions app do not trigger workflows. This restriction is currently in place in order to prevent a circular workflow execution.

Related links:

  • https://github.com/orgs/community/discussions/26169
  • https://github.com/orgs/community/discussions/26236

Edit: The same applies to check events.

like image 93
Xotl Avatar answered Oct 23 '25 20:10

Xotl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!