AI Hints
Home›CI/CD with GitHub Actions Tutorial›Projects: Releases and the Full Pipeline
CI/CD with GitHub Actions · Lesson 122 of 138

Project: Nightly Checks

While you sleep.

⏱ 2 min read▶ Video at 2:22:05🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

Some checks are too slow, or too broad, for every pull request. A nightly workflow runs them on a schedule. Full test suites, dependency audits, and checks against the newest library versions.

Project: Nightly Checks
From the video: Project: Nightly Checks
  • Too slow for every PR
  • Run on a schedule
  • Full suites and audits

nightly.yml

The cron line runs it at three AMUTC every day. Workflow dispatch adds a button, to run it by hand. The job runs the full suite with coverage. And a final step runs only on failure, to tell the team, for example by opening an issue.

.github/workflows/nightly.ymlyaml
name: Nightly
on:
  schedule:
    - cron: "0 3 * * *"
  workflow_dispatch:
jobs:
  nightly:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: pip install -q -r requirements.txt
      - name: Full test suite
        run: pytest -q --cov=app --cov-fail-under=90
      - name: Tell the team
        if: failure()
        run: echo "Nightly failed, opening an issue"

Running it

Our helper runs it as a scheduled event, and everything passes, so the failure step is skipped. A normal push doesn't trigger it at all. Nightly checks stay out of the way, until there's something to report.

Terminal
run-steps .github/workflows/nightly.yml --event schedule | grep -E "^Job|✓|skipped|succeeded"
Job: nightly
  ✓ Run pip install -q -r requirements.txt
  ✓ Full test suite
  - Tell the team  (skipped)
  Job succeeded
run-steps .github/workflows/nightly.yml --event push
Workflow: Nightly  (event: push, branch: main)
  Not triggered: this workflow does not listen for push

Summary

Nightly workflows run slow and broad checks on a schedule, and report only on failure. Next, the final project, a full pipeline.

Key takeaways
  • cron schedule
  • workflow_dispatch
  • if: failure()
Next up: Project: The Full Pipeline — from commit to production