Skip to content

improved link-checker #18

improved link-checker

improved link-checker #18

Workflow file for this run

name: Link Checker
# Trigger the workflow on pull requests to the main or develop branches
on:
pull_request:
branches:
- main
- develop
jobs:
link-check:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository code using the latest version of actions/checkout
- name: Check out code
uses: actions/checkout@v4
# Step 2: Set up Node.js environment using actions/setup-node v4.0.3
- name: Set up Node.js
uses: actions/[email protected]
with:
node-version: '20' # Specify Node.js 20.x
# Step 3: Install npm dependencies
- name: Install dependencies
run: npm install
# Step 4: Create a temporary .eleventy-port file
- name: Create a temporary .eleventy-port file
run: echo "8080" > .eleventy-port
# Step 5: Build and serve the site on a specific port
- name: Build and serve the site
run: npm run serve-only & # Run the Eleventy server in the background
# Step 6: Wait for the server to start
- name: Wait for server to start
run: sleep 15 # Increase the wait time to ensure the server is fully up and running
# Step 7: List site files to verify the build
- name: List site files
run: ls -R _site # Replace with your actual output directory (e.g., _site)
# Step 8: Check if the server is up
- name: Check if server is up
run: |
curl --fail http://localhost:8080/en/index.html || exit 1
continue-on-error: false # Ensure the workflow fails if the server is not up
# Step 9: Run the link checker
- name: Run link checker
id: link-check # Add an ID to reference this step's outputs
run: npm run link-check
# Step 10: Upload the broken links report if it exists
- name: Upload broken links report
if: always() # This runs regardless of the result of the previous step
uses: actions/[email protected]
with:
name: broken-links-report
path: broken-links.json