Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Checking condition when step is running on schedule in GitHub Actions

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:

  1. On pull-request without specific label provided: execute smoke test
  2. On pull-request with specific label OR on schedule: execute full test

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?

like image 452
DJ. Avatar asked Dec 05 '25 21:12

DJ.


1 Answers

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' }}

Reference

like image 128
GuiFalourd Avatar answered Dec 10 '25 10:12

GuiFalourd