Skip to content

Commit

Permalink
feat(ci): add options to disable liquid rendering and run pre-check s…
Browse files Browse the repository at this point in the history
…cript

This commit adds two new options to the Jekyll link checker workflow:

1. `add-no-render-with-liquid`: When set to "true", this option adds `render_with_liquid: false`
   to a set of files (*.md, *.java, *.sd, services.xml, hosts.xml, deployment.xml) before
   building the site. This is useful for preventing liquid rendering in certain files.

2. `pre-check-script`: Allows specifying a path to a script that should be run before
   the link checking step. This can be used to perform additional checks or
   modifications before the main link checking process.

These changes provide more flexibility and control over the build and link
checking process, allowing users to customize the workflow to their specific
needs.
  • Loading branch information
esolitos authored and gitbutler-client committed Aug 14, 2024
1 parent a157bc1 commit 61cca81
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/jekyll-link-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ on:
required: false
type: string
default: ""
build-plugins:
description: |
List of plugins to build before building the site, must be separated by a space.
required: false
type: string
default: ""
add-no-render-with-liquid:
description: |
Set to "true" to adds`render_with_liquid: false` to a set of files before building the site.
File types: *.md, *.java, *.sd, services.xml, hosts.xml, deployment.xml
required: false
type: string
default: "false"
pre-check-script:
description: |
Path to the script to run before checking the links.
required: false
type: string
default: ""

defaults:
run:
Expand All @@ -57,6 +77,21 @@ jobs:
ruby-version: 3.1
bundler-cache: true

- name: Do not render with liquid
if: ${{ inputs.add-no-render-with-liquid == 'true' }}
run: |
find . -not -path './_site/*' \( -name '*.md' -or -name '*.java' -or -name '*.sd' \) | \
while read f; do (echo -e "---\nrender_with_liquid: false\n---\n"; cat ${f})>${f}.new; mv ${f}.new ${f}; done
find . -not -path './_site/*' \( -name services.xml -or -name hosts.xml -or -name deployment.xml \) | \
while read f; do (echo -e "---\nrender_with_liquid: false\n---\n"; cat ${f})>${f}.new; mv ${f}.new ${f}; done
- name: Build Plugins
if: ${{ inputs.build-plugins }}
run: |
for plg in ${{ inputs.build-plugins }}; do
bundle exec jekyll build -p "$plg"
done
- name: Build site
run: |
bundle exec jekyll build
Expand All @@ -74,6 +109,11 @@ jobs:
find _site -name \*.html | xargs sed -i.orig 's/<code[^>]*>//g; s/<\/code>//g; s/<pre[^>]*>//g; s/<\/pre>//g;'
find _site -name \*.orig | xargs rm
- name: Run pre-check script
if: ${{ inputs.pre-check-script }}
run: |
${{ inputs.pre-check-script }}
- name: check links
env:
LANG: "C.UTF-8"
Expand Down

0 comments on commit 61cca81

Please sign in to comment.