From 6a00b7d015bcad182309e53e7cc50c361d97d7e8 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 12 Feb 2024 19:27:40 -0800 Subject: [PATCH] Use custom broken link checker for workflow --- .github/workflows/broken-link-checker.yml | 42 +++++++++++++---------- scripts/linkchecker/main.js | 2 +- scripts/linkchecker/run.sh | 6 ++-- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.github/workflows/broken-link-checker.yml b/.github/workflows/broken-link-checker.yml index 4851fdc5cd..7f118add48 100644 --- a/.github/workflows/broken-link-checker.yml +++ b/.github/workflows/broken-link-checker.yml @@ -1,9 +1,9 @@ -name: Broken Link Check +name: Broken Links Check on: workflow_dispatch: schedule: - - cron: '3 3 * * 0' + - cron: "3 3 * * 0" concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -12,25 +12,31 @@ concurrency: jobs: broken-link-checker: runs-on: ubuntu-latest + if: github.repository == 'owncast/owncast.github.io' + + defaults: + run: + working-directory: ./scripts/linkchecker + steps: - - uses: actions/checkout@v2 + - name: Check out web site code + uses: actions/checkout@v2 with: - submodules: true # Fetch Hugo themes (true OR recursive) - fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + fetch-depth: 0 - - name: Setup Hugo - uses: peaceiris/actions-hugo@v2 + - name: Download lychee + run: | + wget https://github.com/lycheeverse/lychee/releases/download/v0.14.3/lychee-v0.14.3-x86_64-unknown-linux-gnu.tar.gz && tar xvf lychee-v0.14.3-x86_64-unknown-linux-gnu.tar.gz + + - name: Setup nodejs + uses: actions/setup-node@v4 with: - hugo-version: "0.120.4" - extended: true + node-version: latest - - name: Build - run: npm install && hugo --minify + - name: Install dependencies + run: npm install - - name: Check broken links - uses: ruzickap/action-my-broken-link-checker@v2 - with: - url: https://owncast.online/docs - pages_path: ./public/ - cmd_params: '--buffer-size=8192 --max-connections=10 --color=always --rate-limit=1 --max-connections-per-host 3 --skip-tls-verification --exclude="opencollective.com|github.com|example.com|mydomain.com|sitemap" --verbose' - debug: true \ No newline at end of file + - name: Run link checker + run: ./run.sh + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} diff --git a/scripts/linkchecker/main.js b/scripts/linkchecker/main.js index 96e80a65be..b9d792519c 100644 --- a/scripts/linkchecker/main.js +++ b/scripts/linkchecker/main.js @@ -32,7 +32,7 @@ async function run() { let issueCheck; try { - issueCheck = await searchForIssue(failedUrl); + issueCheck = await searchForIssue(link); await sleep(2000); if (issueCheck) { console.log("Issue already exists"); diff --git a/scripts/linkchecker/run.sh b/scripts/linkchecker/run.sh index 356026613b..f19905849e 100755 --- a/scripts/linkchecker/run.sh +++ b/scripts/linkchecker/run.sh @@ -1,2 +1,4 @@ -./lychee --github-token $GITHUB_TOKEN --exclude-path ../../content/releases -f json https://owncast.online/docs ../../content >links.json -GITHUB_TOKEN=$GITHUB_TOKEN node main.js +#!/bin/sh + +./lychee --github-token "$GITHUB_TOKEN" --exclude-path ../../content/releases -f json https://owncast.online/docs ../../content >links.json +GITHUB_TOKEN="$GITHUB_TOKEN" node main.js