Create дворфы.md #1
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: "Link Checker" | |
on: | |
pull_request: | |
paths: | |
- '00_Правила_оформления/**/*.md' | |
- '01_Вселенная/**/*.md' | |
- '02_Станция/**/*.md' | |
- '03_Государства/**/*.md' | |
- '04_Корпорации/**/*.md' | |
- '05_Организации/**/*.md' | |
- '06_Расы/**/*.md' | |
- '07_Существа/**/*.md' | |
- '08_Технологии/**/*.md' | |
- '09_Вооружение/**/*.md' | |
- '10_Явления/**/*.md' | |
- '11_Товары/**/*.md' | |
- '12_Другое/**/*.md' | |
- '13_Истории/**/*.md' | |
- '14_Повседневность/**/*.md' | |
jobs: | |
link-check: | |
runs-on: ubuntu-latest | |
steps: | |
# Проверка репозитория | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Установка lychee | |
- name: Установка Lychee | |
run: cargo install lychee | |
# Запуск проверки ссылок | |
- name: Проверка ссылок в Markdown | |
id: link-check | |
run: lychee --output json --dump ./lychee-output.json "**/*.md" || echo "Обнаружены проблемы со ссылками." | |
# Отправка комментария к PR | |
- name: Комментарий к PR с результатами | |
if: always() | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const outputFile = './lychee-output.json'; | |
if (!fs.existsSync(outputFile)) { | |
github.rest.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Не удалось создать отчет о проверке ссылок. Убедитесь, что Markdown файлы доступны для проверки.', | |
}); | |
return; | |
} | |
const output = JSON.parse(fs.readFileSync(outputFile, 'utf8')); | |
if (!output.links || output.links.length === 0) { | |
github.rest.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '🔍 В файлах Markdown не обнаружено ссылок.', | |
}); | |
return; | |
} | |
const failedLinks = output.links.filter(link => link.status !== 'Ok'); | |
if (failedLinks.length === 0) { | |
github.rest.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: '✅ Все ссылки в файлах Markdown корректны!', | |
}); | |
return; | |
} | |
const errorDetails = failedLinks | |
.map(link => `- [${link.uri}](${link.uri}) (Файл: ${link.source}) → Статус: ${link.status}`) | |
.join('\n'); | |
const issueComment = ` | |
### Отчет о проверке ссылок | |
Обнаружены следующие проблемы со ссылками: | |
${errorDetails} | |
Пожалуйста, исправьте их перед слиянием. | |
`; | |
github.rest.issues.createComment({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: issueComment, | |
}); |