From 30f3c14465e1d9d5be061721406dde4f142ecac3 Mon Sep 17 00:00:00 2001 From: George <31376482+george-gca@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:38:06 -0300 Subject: [PATCH] Link checks on deploy (#2079) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added another GitHub action to check for broken local links on version of the site that will be deployed. The `broken-links` action check for broken links considering documentation files (like INSTALLING.md) and also pages like [_pages/about.md](https://github.com/alshedivat/al-folio/blob/master/_pages/about.md), but it can't check for broken links when the link will be handled by jekyll tags (like in [_pages/blog.md](https://github.com/alshedivat/al-folio/blob/master/_pages/blog.md). With `broken-links-site` we can check if all the links that will be used on the final site that refer to local files are correct. Focusing only on local files since this would end up calling too many checks for library files, like `https://unpkg.com/bootstrap-table@1.22.1/dist/bootstrap-table.min.css`. --------- Signed-off-by: George Araújo --- .github/workflows/broken-links-site.yml | 52 +++++++++++++++++++++++++ .github/workflows/deploy.yml | 2 +- .github/workflows/prettier.yml | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/broken-links-site.yml diff --git a/.github/workflows/broken-links-site.yml b/.github/workflows/broken-links-site.yml new file mode 100644 index 0000000..4ed2624 --- /dev/null +++ b/.github/workflows/broken-links-site.yml @@ -0,0 +1,52 @@ +name: Check for broken links on site + +on: + push: + branches: + - master + - main + pull_request: + branches: + - master + - main + workflow_dispatch: + +permissions: + contents: write + +jobs: + deploy: + # available images: https://github.com/actions/runner-images#available-images + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2.2" + bundler-cache: true + - name: Update _config.yml ⚙️ + uses: fjogeleit/yaml-update-action@v0.13.1 + with: + commitChange: false + valueFile: "_config.yml" + changes: | + { + "giscus.repo": "${{ github.repository }}", + "baseurl": "" + } + - name: Install and Build 🔧 + run: | + pip3 install --upgrade jupyter + npm install -g mermaid.cli + npm install -g purgecss + export JEKYLL_ENV=production + bundle exec jekyll build --lsi + purgecss -c purgecss.config.js + - name: Link Checker 🔗 + uses: lycheeverse/lychee-action@v1.9.0 + with: + fail: true + # only check local links + args: --offline --remap '_site(/?.*)/assets/(.*) _site/assets/$2' --verbose --no-progress '_site/**/*.html' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9bae548..908e32e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: deploy +name: Deploy site on: push: diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml index 8047676..3749b4f 100644 --- a/.github/workflows/prettier.yml +++ b/.github/workflows/prettier.yml @@ -1,4 +1,4 @@ -name: prettier +name: Prettier code formatter on: push: