#DevHack: GitHub Actions do not run step on schedule
This post is over a year old, some of this information may be out of date.
When creating a whole new Github Actions workflow for Doctor, I wanted to do as much as possible from one workflow and be able to limit specific actions depending on how it triggered.
I wanted my GitHub Actions to run on each push to the dev
and main
branch and run the tests on a schedule. Instead of creating two workflows, I wanted to use only one workflow and specify not to run my release step to npm when triggered on a schedule
.
The condition for this is relatively easy. All you need to know is the event type
and the property name to use.
You can find all property names on the context and expression syntax for GitHub Actions. The one we need for the workflow is github.event_name
.
You can find the event name values on the [events that trigger the workflows](Events that trigger workflows - GitHub Docs) page. In this case, the value is schedule
.
The condition its implementation looks as follows:
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2
- name: Do not run on a schedule run: echo Just a message. if: ${{ github.event_name != 'schedule' }}
This results in:

Related articles
Report issues or make changes on GitHub
Found a typo or issue in this article? Visit the GitHub repository to make changes or submit a bug report.
Comments
Let's build together
Manage content in VS Code
Present from VS Code