Skip to content

governance.link-checker #22

governance.link-checker

governance.link-checker #22

# @todo: sync with other repositories
---
name: governance.link-checker
# Run action on pull request event
on:
push:
branches:
- $default-branch
paths:
- '*.md'
pull_request:
types: [opened, edited]
paths:
- '*.md'
schedule:
- cron: "0 9 * * 1"
workflow_dispatch:
env:
TEMPLATE: .github/templates/issue.links.md
LYCHEE_OUT: out.md
USER_AGENT: "Mozilla/5.0 (X11; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0"
jobs:
markdown-link-check:
runs-on: ubuntu-latest
if: github.repository == 'ivankatliarchuk/.github'
steps:
# checkout to latest commit
- uses: actions/checkout@v4.1.7
# run markdown linter
# todo https://github.com/peter-evans/link-checker
- name: link checker
id: lychee
uses: lycheeverse/lychee-action@v1.10.0
# if: failure()
with:
args: >
--exclude="^(javascript|chrome):.*"
--exclude "^git"
--exclude "^file://"
--verbose
--no-progress
--accept=200,403,429
--timeout 20
"*.md"
"**/*.md"
"README.md"
"*.toml"
"**/*.toml"
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: read output
id: readfile
uses: juliangruber/read-file-action@v1.1.7
if: ${{ steps.lychee.outputs.exit_code > 0 }}
with:
path: ${{ env.LYCHEE_OUT }}
- name: results
id: read
run: |
echo "exit code: ${{ steps.lychee.outputs.exit_code }}"
- name: update issue template
uses: DamianReeves/write-file-action@master
if: ${{ steps.lychee.outputs.exit_code > 0 }}
with:
path: .github/templates/issue.links.md
contents: ${{ steps.readfile.outputs.content }}
write-mode: append
- name: create issue from file
uses: JasonEtco/create-an-issue@v2.9.2
id: issue
if: ${{ steps.lychee.outputs.exit_code > 0 }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TITLE: 'Markdwon links checker'
with:
filename: ${{ env.TEMPLATE }}
assignees: ${{ github.repository_owner }}
update_existing: true
- name: fail if there were link errors
run: exit ${{ steps.lychee.outputs.exit_code }}