Reputation: 6784
We have workflow in GitHub Actions
which has both types that trigger on event, e.g.pull-request, and on schedule.
Most of the steps are the same except for running test step. What we would like is:
The check for label can be done with contains(github.event.pull_request.labels.*.name, 'full-tests')
.
The question is how to check when the it is run on schedule? From my understanding of the documentation, when on schedule there is no payload for github.event
for schedule. However checking github.event == null
doesn't seems to work.
Is there a specific way to check whether it is running on schedule?
Upvotes: 18
Views: 8793
Reputation: 23190
What you want to use in that case is the github.event_name
variable, which represents the name of the event that triggered the workflow run in the github context.
In your case, to run a job or a step if the workflow run triggered on a scheduled event, you will need to use:
if: ${{ github.event_name == 'schedule' }}
Upvotes: 33