Delay GitHub Actions builds
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
<PIPELINE>
: The name of your pipeline.<RUN_ON>
: The runner to use, see GitHub’s own documentation for possible values.<CRON>
: cron expression - use https://crontab.guru/.<DATE>
: Git date expression that matches<CRON>
.