Merge pull request #297 from DEFRA/fix/DF-648-form-status #156
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Documentation Generation | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| test-docs-generation: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages-test | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Check out code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Set branch type based on trigger | |
| id: set-branch | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "BRANCH_TYPE=${{ github.event.inputs.branch_type }}" >> $GITHUB_ENV | |
| else | |
| echo "BRANCH_TYPE=main" >> $GITHUB_ENV | |
| fi | |
| echo "VERSION=1.2.3" >> $GITHUB_ENV | |
| - name: Generate documentation | |
| run: | | |
| mkdir -p .github/scripts/docs | |
| bash .github/scripts/docs/generate-and-publish-docs.sh "$BRANCH_TYPE" "$VERSION" | |
| - name: Create Jekyll source directory | |
| run: | | |
| # Create Jekyll source directory | |
| mkdir -p site-src | |
| # First, copy all docs to site-src | |
| cp -r docs/* site-src/ | |
| - name: Generate schema documentation | |
| run: | | |
| echo "🔄 Generating schema documentation..." | |
| node scripts/generate-schema-docs.js | |
| - name: Process schema documentation and prepare for Jekyll | |
| run: | | |
| echo "🔄 Processing documentation files..." | |
| cd site-src | |
| chmod +x ../.github/scripts/docs/process-docs.sh | |
| ../.github/scripts/docs/process-docs.sh | |
| cd .. | |
| - name: Fix documentation links | |
| run: | | |
| echo "🔄 Fixing documentation links..." | |
| cd site-src | |
| chmod +x ../.github/scripts/docs/fix-schema-links.sh | |
| ../.github/scripts/docs/fix-schema-links.sh | |
| cd .. | |
| - name: Fix Liquid templates and create lowercase files | |
| run: | | |
| echo "🔄 Fixing Liquid templates and creating lowercase files..." | |
| cd site-src | |
| chmod +x ../.github/scripts/docs/fix-docs.sh | |
| ../.github/scripts/docs/fix-docs.sh | |
| cd .. | |
| - name: Create Jekyll configuration | |
| run: | | |
| echo "🔄 Creating Jekyll configuration files..." | |
| chmod +x .github/scripts/docs/create-jekyll-config.sh | |
| .github/scripts/docs/create-jekyll-config.sh | |
| - name: Build and verify Jekyll site | |
| run: | | |
| # Build the site | |
| echo "🔨 Building Jekyll site..." | |
| cd site-src | |
| bundle install | |
| JEKYLL_ENV=production bundle exec jekyll build --destination ../_site | |
| cd .. | |
| # Verification steps | |
| echo "🔍 Verifying build results..." | |
| # Show root files explicitly | |
| echo "📄 Files at site root:" | |
| ls -la _site/ | |
| # Check for HTML files | |
| echo "✓ HTML files generated from markdown:" | |
| find _site -name "*.html" | grep -v "assets" | head -n 15 | |
| html_count=$(find _site -name "*.html" | wc -l) | |
| echo " Total HTML files: $html_count" | |
| # Check if any markdown files remain in output (there shouldn't be any) | |
| md_files=$(find _site -name "*.md" | wc -l) | |
| if [ "$md_files" -gt 0 ]; then | |
| echo "⚠️ WARNING: Found $md_files markdown files in output (should be 0):" | |
| find _site -name "*.md" | head -n 10 | |
| else | |
| echo "✅ No markdown files found in output (good!)" | |
| fi | |
| # Check for specific problematic files to make sure they were converted | |
| for check_file in "features/configuration-based/PAGE_TEMPLATES.html" "features/configuration-based/PAGE_EVENTS.html" "features/code-based/PAGE_VIEWS.html"; do | |
| if [ -f "_site/$check_file" ]; then | |
| echo "✅ Successfully converted: $check_file" | |
| else | |
| echo "❌ FAILED to convert: $check_file" | |
| fi | |
| done | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: '_site' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| timeout: 600000 # 10 minutes in milliseconds |