I want to trigger a workflow only if a particular workflow finishes... does anyone know how to do that?
Some context:
Tests
and another called Build-feature
.Tests
workflow on every PR to branch feature
.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?.
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:
Edit:
The same applies to check
events.