From ba0ee00df47440e97ebacda849be74e63aca650d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Wed, 4 May 2022 08:05:02 -0400 Subject: [PATCH] chore: add lint checking for out markdown files in CI --- .github/workflows/links_checker.yml | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/links_checker.yml diff --git a/.github/workflows/links_checker.yml b/.github/workflows/links_checker.yml new file mode 100644 index 000000000..27878db49 --- /dev/null +++ b/.github/workflows/links_checker.yml @@ -0,0 +1,79 @@ +name: Links Checker + +on: + ## Allow triggering this workflow manually via GitHub CLI/web + workflow_dispatch: + + ## Run this workflow automatically every week + schedule: + - cron: '0 0 * * 1' + +jobs: + link_checker: + name: Check links and create automated issue if needed + runs-on: ubuntu-latest + env: + LYCHEE_OUT: ./lychee/links-report + steps: + ## Check out code using Git + - uses: actions/checkout@v3 + + - name: Check all links at *.md and doc files + id: lychee + uses: lycheeverse/lychee-action@v1.4.1 + with: + output: ${{ env.LYCHEE_OUT }} + format: markdown + ## Do not fail this step on broken links + fail: false + ## Allow pages replying with 200 (Ok)in at most 20 seconds + ## This checks all md files in the repo + args: >- + --verbose + --accept 200 + --timeout 20 + --max-concurrency 10 + --no-progress + './**/*.md' + env: + ## Avoid rate limiting when checking github.com links + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Find the last report issue open + uses: micalevisk/last-issue-action@v1.2 + id: last_issue + with: + state: open + labels: | + report + automated issue + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create issue from report file + if: ${{ steps.last_issue.outputs.has_found == 'false' }} + uses: peter-evans/create-issue-from-file@v4 + with: + title: Link checker report + content-filepath: ${{ env.LYCHEE_OUT }} + issue-number: ${{ steps.last_issue.outputs.issue_number }} + labels: | + report + automated issue + + - name: Update last report open issue created + if: ${{ steps.last_issue.outputs.has_found == 'true' }} + uses: peter-evans/create-issue-from-file@v4 + with: + title: Link checker report + content-filepath: ${{ env.LYCHEE_OUT }} + issue-number: ${{ steps.last_issue.outputs.issue_number }} + labels: | + report + automated issue + + - name: Close last report open issue + if: ${{ steps.lychee.outputs.exit_code == 0 }} + uses: peter-evans/close-issue@v2 + with: + issue-number: ${{ steps.last_issue.outputs.issue_number }}