.github/workflows/repo_linter.sh
22 lines · 563 bytes · executable
1#!/bin/bash
2
3# Find the repo in the git diff and then set it to an env variables.
4REPO_TO_LINT=$(
5 git diff origin/main -- readme.md |
6 # Look for changes (indicated by lines starting with +).
7 grep ^+ |
8 # Get the line that includes the readme.
9 grep -Eo 'https.*#readme' |
10 # Get just the URL.
11 sed 's/#readme//')
12
13# If there's no repo found, exit quietly.
14if [ -z "$REPO_TO_LINT" ]; then
15 echo "No new link found in the format: https://....#readme"
16else
17 echo "Cloning $REPO_TO_LINT"
18 mkdir cloned
19 cd cloned
20 git clone "$REPO_TO_LINT" .
21 npx awesome-lint
22fi