|
| 1 | +name: Docs Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths: |
| 6 | + - 'docs/**' |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - 'docs/**' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + working-directory: docs |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Set up Ruby |
| 22 | + uses: ruby/setup-ruby@v1 |
| 23 | + with: |
| 24 | + ruby-version: '3.3' |
| 25 | + bundler-cache: true |
| 26 | + working-directory: docs |
| 27 | + |
| 28 | + - name: Build Jekyll site |
| 29 | + run: bundle exec jekyll build --baseurl /flextensions |
| 30 | + env: |
| 31 | + JEKYLL_ENV: production |
| 32 | + PAGES_REPO_NWO: berkeley-cds/flextensions |
| 33 | + |
| 34 | + - name: Check for broken internal links |
| 35 | + run: | |
| 36 | + # Verify all internal .html files were generated |
| 37 | + echo "Generated site files:" |
| 38 | + find _site -name '*.html' | sort |
| 39 | + echo "" |
| 40 | + echo "Checking for broken internal links..." |
| 41 | + # Extract internal href links and verify they resolve |
| 42 | + broken=0 |
| 43 | + for file in $(find _site -name '*.html'); do |
| 44 | + # Extract href values pointing to /flextensions/ paths |
| 45 | + grep -oP 'href="(/flextensions/[^"]*)"' "$file" 2>/dev/null | while read -r match; do |
| 46 | + path=$(echo "$match" | grep -oP '"/flextensions/[^"]*"' | tr -d '"') |
| 47 | + # Convert URL path to file path |
| 48 | + local_path="_site${path#/flextensions}" |
| 49 | + # Check if it's a directory (index.html) or file |
| 50 | + if [ -d "$local_path" ] && [ -f "$local_path/index.html" ]; then |
| 51 | + continue |
| 52 | + elif [ -f "$local_path" ]; then |
| 53 | + continue |
| 54 | + elif [ -f "${local_path}.html" ]; then |
| 55 | + continue |
| 56 | + elif [ -f "${local_path%/}/index.html" ]; then |
| 57 | + continue |
| 58 | + else |
| 59 | + echo "::warning file=$file::Broken link: $path (resolved to $local_path)" |
| 60 | + broken=1 |
| 61 | + fi |
| 62 | + done |
| 63 | + done |
| 64 | + if [ "$broken" -eq 1 ]; then |
| 65 | + echo "::warning::Some internal links may be broken. Check warnings above." |
| 66 | + fi |
0 commit comments