Delay GitHub Actions builds View article history Edit article

Published: , Updated:
Talks about: <a class="post-tag post-tag-github" href="/tags/github">github</a>, <a class="post-tag post-tag-github-actions" href="/tags/github-actions">github actions</a>, and <a class="post-tag post-tag-schedule" href="/tags/schedule">schedule</a>

To delay the execution of an GitHub Action, use a mixture of the on: schedule: ... configuration, and a conditional build step.

name: <PIPELINE>
on:
  schedule:
    - cron: '<CRON>'
jobs:
  build:
    runs-on: <RUN_ON>
    steps:
      - name: Count commits in last week
        id: commits
        run: echo "::set-output name=count::$(git rev-list --count HEAD --since='<DATE>')"
      - name: Build project
        if: steps.commits.outputs.count > 0
        run: build-project