Commit ec9672252a
Unregistered key
Layout: unified · split
.github/workflows/main.yml added +14
| @@ -0,0 +1,14 @@ | |||
| 1 | on: | ||
| 2 | pull_request: | ||
| 3 | branches: [main] | ||
| 4 | paths: | ||
| 5 | - 'readme.md' | ||
| 6 | jobs: | ||
| 7 | lint: | ||
| 8 | runs-on: ubuntu-latest | ||
| 9 | steps: | ||
| 10 | - uses: actions/checkout@v2 | ||
| 11 | with: | ||
| 12 | fetch-depth: 0 | ||
| 13 | - name: awesome-lint | ||
| 14 | run: ./.github/workflows/repo_linter.sh | ||
.github/workflows/repo_linter.sh added +22
| @@ -0,0 +1,22 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Find the repo in the git diff and then set it to an env variables. | ||
| 4 | REPO_TO_LINT=$( | ||
| 5 | git diff 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. | ||
| 14 | if [ -z ${REPO_TO_LINT+x} ]; then | ||
| 15 | echo "No new link found in the format: https://....#readme" | ||
| 16 | else | ||
| 17 | echo "Cloning $REPO_TO_LINT" | ||
| 18 | mkdir cloned | ||
| 19 | cd cloned | ||
| 20 | git clone --depth=1 "$REPO_TO_LINT" . | ||
| 21 | npx awesome-lint | ||
| 22 | fi | ||