-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,21 +2,20 @@ | |
|
||
name: Awesome Lint | ||
|
||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
branches: [main] | ||
paths: | ||
- 'readme.md' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
- uses: max/[email protected] | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: awesome-lint | ||
run: ./.github/workflows/repo_linter.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
# Find the repo in the git diff and then set it to an env variables. | ||
REPO_TO_LINT=$( | ||
git diff origin/main -- readme.md | | ||
# Look for changes (indicated by lines starting with +). | ||
grep ^+ | | ||
# Get the line that includes the readme. | ||
grep -Eo 'https.*#readme' | | ||
# Get just the URL. | ||
sed 's/#readme//') | ||
|
||
# If there's no repo found, exit quietly. | ||
if [ -z "$REPO_TO_LINT" ]; then | ||
echo "No new link found in the format: https://....#readme" | ||
else | ||
echo "Cloning $REPO_TO_LINT" | ||
mkdir cloned | ||
cd cloned | ||
git clone "$REPO_TO_LINT" . | ||
npx awesome-lint | ||
fi |