repo_linter.sh 563 B

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