Skip to content

Trigger Workflows

GitHub workflows are triggered by events.

Events related to a GitHub workflow include

Scheduled Version Check

Scheduled Version Check GitHub workflow uses the cron schedule to check for newer versions of Clojure libraries and GitHub actions

Cron schedule

GitHub workflows can use cron: to define a schedule as to when a workflow should run.

A POSIX Cron pattern is used to define the schedule

  • Minute [0,59]
  • Hour [0,23]
  • Day of the month [1,31]
  • Month of the year [1,12]
  • Day of the week ([0,6] with 0=Sunday)
    name: "Scheduled Version Check"
    on:
      schedule:
        - cron: "0 4 * * *" # at 04:04:04 ever day
        # - cron: "0 4 * * 5" # at 04:04:04 ever Friday
        # - cron: "0 4 1 * *" # at 04:04:04 on first day of month
Cron references

Workflow Dispatch

Add workflow_dispatch: without arguments to the on: directive in a workflow configuration file to manually trigger the running of the workflow.

Visit GitHub.com > Actions > Workflow Name in the repository and select Run

Workflow with Manual Trigger
---
name: Publish Book
on:
  # Manually trigger workflow
  workflow_dispatch:

Conditional on another workflow

workflow_run: defines that a workflow should only run if the outcome of another GitHub workflow run completed with success.

Run workflow if MegaLinter workflow returns success
    name: "Publish Documentation"
    on:
      # Run work flow conditional on linter workflow success
      workflow_run:
        workflows:
          - "MegaLinter"
        paths-ignore:
          - README.md
          - CHANGELOG.md
          - .gitignore
        branches:
          - main
        types:
          - completed