File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed
Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Check badges in README.md
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ build-and-test :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - uses : actions/checkout@v3
15+
16+ - name : Check badges in README.md
17+ run : ./scripts/check-badges.bash "README.md"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -euo pipefail
3+
4+ readme_file=$1
5+
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd ) "
7+
8+ pushd " ${SCRIPT_DIR} /.."
9+
10+ grep -oP ' [^/]+\.yml(?=/badge.svg)' " ${readme_file} " || (>&2 echo " No badges in ${readme_file} " ; exit 1) | while read -r workflow_file; do
11+ path_to_workflow=" .github/workflows/${workflow_file} "
12+ if [ ! -e " ${path_to_workflow} " ]
13+ then
14+ >&2 echo " Error, workflow does not exist \" ${path_to_workflow} \" "
15+ exit 1
16+ fi
17+ done
18+
19+ grep -oP ' [^/]+\.yml/badge.svg(?!\?branch=main)' " ${readme_file} " || echo | while read -r badge_without_branch; do
20+ if [ -z " ${badge_without_branch} " ]; then continue ; fi
21+ >&2 echo " Badge without branch \" ${badge_without_branch} \" "
22+ exit 1
23+ done
24+
25+ popd
You can’t perform that action at this time.
0 commit comments