Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How having schedule AND push/pull_request events in a GitHub workflow?

I would like to run a workflow if a push/pull_request events is trigger OR when a schedule event is trigger...

Here my broken (syntax issue) .github/workflows/docker.yml:

name: Docker

on: [push, pull_request]
  schedule:
    # min hours day(month) month day(week)
    - cron: '0 0 */5 * *'

...

Unfortunately this syntax is wrong, here the error:

Invalid workflow file
You have an error in your yaml syntax on line 3
like image 317
Mizux Avatar asked Sep 07 '26 20:09

Mizux


1 Answers

According to the doc:

Example using multiple events with activity types or configuration
If you need to specify activity types or configuration for an event, you must configure each event separately. You must append a colon (:) to all events, including events without configuration.

ref: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-using-multiple-events-with-activity-types-or-configuration

So here we can't use a list of events...

name: Docker

on: 
  push:
  pull_request:
  schedule:
    # min hours day(month) month day(week)
    - cron: '0 0 */5 * *'

...
like image 59
Mizux Avatar answered Sep 10 '26 14:09

Mizux



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!