Рецепт "Мгновенная валидация форм" #8126
Workflow file for this run
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
name: PR Checks | |
on: | |
pull_request: | |
jobs: | |
editorconfig: | |
name: Форматирование | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- id: files | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: Ana06/[email protected] | |
- name: Работает линтер | |
run: | | |
npm install editorconfig-checker --global | |
config=.editorconfig | |
for changed_file in ${{ steps.files.outputs.added_modified }}; do | |
if [ $changed_file == $config ] | |
then | |
echo "Проверка для всех файлов" | |
editorconfig-checker | |
break | |
else | |
echo "Проверка для ${changed_file}" | |
editorconfig-checker ${changed_file} | |
fi | |
done | |
frontmatter-checker: | |
name: Мета | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- id: files | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: Ana06/[email protected] | |
with: | |
filter: | | |
(css|html|js|tools|a11y)/**/index.md | |
!(pages|people)/**/index.md | |
- name: Работает линтер | |
run: | | |
files='${{ steps.files.outputs.added_modified }}' | |
if ! [[ $files == "" ]]; then | |
echo "Проверка для файлов из PR" | |
npx yaml-cat --format json --output result.json $(echo $files | grep -o -E '(css|html|js|tools|a11y)/[a-z-]+/index.md') | |
node .github/scripts/frontmatter.js | |
else | |
echo "В PR нет файлов для проверки" | |
fi | |
link-checker: | |
name: Ссылки | |
needs: | |
- editorconfig | |
- frontmatter-checker | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- id: files | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: Ana06/[email protected] | |
with: | |
filter: '*.md' | |
format: 'csv' | |
- name: Проверяет ссылки | |
if: ${{ steps.files.outputs.added_modified != '' }} | |
uses: JustinBeckwith/linkinator-action@v1 | |
with: | |
paths: ${{ steps.files.outputs.added_modified }} | |
markdown: true | |
serverRoot: "/home/runner/work/content/content" | |
linksToSkip: "https?://(localhost|codepen.io)?(:[0-9]+)?/.*" | |
yaspeller: | |
name: Орфография | |
needs: | |
- link-checker | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- id: files | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: Ana06/[email protected] | |
- name: Проверяет правописание | |
run: | | |
config=.yaspeller.json | |
file_list="" | |
for changed_file in ${{ steps.files.outputs.added_modified }}; do | |
if [[ $changed_file == $config ]]; then | |
echo "Проверяются все файлы..." | |
npx yaspeller --only-errors --file-extensions ".md,.html" * | |
break | |
elif [[ $changed_file =~ \.(md|html)$ ]]; then | |
file_list="${file_list} ${changed_file}" | |
echo "Файл ${changed_file} добавлен в список для проверки." | |
fi | |
done | |
if ! [[ $file_list == "" ]]; then | |
echo "Проверяются файлы из PR..." | |
npx yaspeller --only-errors ${file_list} | |
fi |