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