From 6ef8c78e06fcc43c9d376a50c68d3d7e899b2035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gast=C3=B3n=20Fournier?= Date: Wed, 7 Sep 2022 15:31:38 +0200 Subject: [PATCH] docs: test broken links in website (#1912) The action triggers manually as a first step to test this functionality. In the near future, we might schedule it --- .github/workflows/build_doc_prs.yaml | 1 - .github/workflows/check_links.yaml | 55 ++++++++++++++++++++++++++++ .lycheeignore | 20 ++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check_links.yaml create mode 100644 .lycheeignore diff --git a/.github/workflows/build_doc_prs.yaml b/.github/workflows/build_doc_prs.yaml index b010074737..46971c60c6 100644 --- a/.github/workflows/build_doc_prs.yaml +++ b/.github/workflows/build_doc_prs.yaml @@ -7,7 +7,6 @@ on: jobs: validate: - runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/check_links.yaml b/.github/workflows/check_links.yaml new file mode 100644 index 0000000000..9a202b83fc --- /dev/null +++ b/.github/workflows/check_links.yaml @@ -0,0 +1,55 @@ +name: Check links + +on: + workflow_dispatch: + +jobs: + validate: + runs-on: ubuntu-latest + permissions: + contents: read + issues: write + env: + issue-lookup-label: automated-link-issue + issue-content: ./lychee-out.md + steps: + - uses: actions/checkout@v3 + - name: Restore lychee cache + uses: actions/cache@v3 + with: + path: .lycheecache + key: cache-lychee-${{ github.sha }} + restore-keys: cache-lychee- + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@v1.5.0 + with: + fail: true + args: '"./website/docs/**/*.md" "./website/docs/**/*.mdx" "./src/mailtemplates/*.mustache" --scheme http --scheme https --cache --max-cache-age 7d --exclude-mail --verbose' # other excludes are in .lycheeignore + output: ${{ env.issue-content }} + + # Permissions (issues: read) + - name: 'Look for an existing issue' + if: ${{ failure() }} + id: last-issue + uses: micalevisk/last-issue-action@v2 + # Find the last updated open issue with a `automated-issue` label: + with: + state: open + labels: ${{ env.issue-lookup-label }} + + # Permissions (issues: write) + - name: 'Create a new issue, or update an existing one' + if: ${{ failure() }} + uses: peter-evans/create-issue-from-file@v4 + with: + title: 'docs: Broken links found' + content-filepath: ${{ env.issue-content }} + # Update an existing issue if one was found (issue_number), + # otherwise an empty value creates a new issue: + issue-number: ${{ steps['last-issue']['outputs']['issue-number'] }} + # Add a label(s) that `last-issue` can use to find this issue, + # and any other relevant labels for the issue itself: + labels: | + ${{ env.issue-lookup-label }} + docs diff --git a/.lycheeignore b/.lycheeignore new file mode 100644 index 0000000000..7c06608257 --- /dev/null +++ b/.lycheeignore @@ -0,0 +1,20 @@ +dev-example-okta.com +.*-dsn.algolia.net +www.linkedin.com/company/getunleash + +.*.unleash.host.*.com.* +unleash.*.com/api/ +secure-unleash.herokuapp.com + +localhost +changeme +hostname +unleash:4242 +user:password@url +your.heroku.instance.com +your-api-url +version.unleash.run + +datadog.*/api/v1/events +ddog.*/api/v1/events +api.datadoghq.com \ No newline at end of file