AI Hints
CI/CD with GitHub Actions · Lesson 72 of 138

Status Badges

Green at a glance.

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

Many projects show a small badge at the top of their readme, saying whether the build is passing. It's a quick signal for visitors, and a gentle reminder for the team to keep it green.

Status Badges
From the video: Status Badges
  • A badge in the readme
  • Passing or failing
  • Keep it green

Adding a badge

GitHub makes a badge image for every workflow, at a fixed address. The owner, the repository, actions, workflows, the file name, and badge dot SVG. We add a markdown image line to the top of the readme. On GitHub, it shows a green passing label, or a red failing one.

Terminal
sed -i '1a ![CI](https://github.com/sam/shop/actions/workflows/ci.yml/badge.svg)' README.md
cat README.md
# Shop
![CI](https://github.com/sam/shop/actions/workflows/ci.yml/badge.svg)
A tiny shop library.

Badge options

Add a query like branch equals main, to show only the main branch's status. Badges also exist for coverage, versions, and licences, from services like shields dot IO. Use a few that matter. A wall of badges is just noise.

keyvalue
badge.svgper workflow
?branch=mainone branch
shields.iomany other badges
A fewnot a wall

Summary

Workflow badges show build status in your readme. Keep them few and meaningful. Next, how CI fits into code review.

Key takeaways
  • …/workflows/ci.yml/badge.svg
  • In the README
  • ?branch=main
Next up: Code Review with CI — people and machines