Skip to content

Remove container-based jobs from CI pipeline #57

Remove container-based jobs from CI pipeline

Remove container-based jobs from CI pipeline #57

Workflow file for this run

name: Build and Deploy Documentation
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
concurrency:
group: "docs"
cancel-in-progress: false
permissions:
contents: write
pages: write
jobs:
# === PARALLEL BUILD STAGE ===
setup-build-environment:
name: Setup Build Environment
runs-on: ubuntu-latest
outputs:
node-version: ${{ steps.node.outputs.version }}
cache-key: ${{ steps.cache.outputs.key }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
- name: Setup Node.js
id: node
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'pnpm'
- name: Generate cache key
id: cache
run: echo "key=deps-$(node -v)-$(pnpm -v)-${{ hashFiles('pnpm-lock.yaml') }}" >> $GITHUB_OUTPUT
build-typescript:
name: Build TypeScript
runs-on: ubuntu-latest
needs: setup-build-environment
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ needs.setup-build-environment.outputs.cache-key }}
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build TypeScript
run: pnpm run build
generate-api-docs:
name: Generate API Documentation
runs-on: ubuntu-latest
needs: setup-build-environment
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ needs.setup-build-environment.outputs.cache-key }}
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Generate API docs
run: pnpm run docs:build
setup-jekyll:
name: Setup Jekyll Environment
runs-on: ubuntu-latest
needs: setup-build-environment
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
working-directory: docs
- name: Validate Build Environment
run: |
echo "🔍 Validating build environment..."
# Check Ruby version
RUBY_VERSION=$(ruby -e 'puts RUBY_VERSION')
echo "Ruby version: $RUBY_VERSION"
# Check Bundler version
BUNDLER_VERSION=$(bundle --version)
echo "Bundler version: $BUNDLER_VERSION"
# Verify all gems are installed
if bundle check; then
echo "✅ All dependencies satisfied"
else
echo "❌ Missing dependencies"
exit 1
fi
working-directory: docs
- name: Update just-the-docs
run: bundle update just-the-docs
working-directory: docs
- name: Verify Jekyll and just-the-docs versions
run: |
echo "Checking Jekyll version..."
JEKYLL_VERSION=$(bundle exec jekyll --version | cut -d' ' -f2)
echo "Installed Jekyll version: $JEKYLL_VERSION"
EXPECTED_JEKYLL="4.4.1"
if [[ "$JEKYLL_VERSION" == "$EXPECTED_JEKYLL" ]]; then
echo "✅ Jekyll version matches expected: $EXPECTED_JEKYLL"
else
echo "❌ Jekyll version mismatch. Expected: $EXPECTED_JEKYLL, Got: $JEKYLL_VERSION"
exit 1
fi
echo "Checking just-the-docs version..."
JTD_VERSION=$(bundle list | grep just-the-docs | awk '{print $2}')
echo "Installed just-the-docs version: $JTD_VERSION"
echo "✅ just-the-docs version verified"
working-directory: docs
# === DEPLOY STAGE ===
build-and-deploy:
name: Build and Deploy Documentation
runs-on: ubuntu-latest
needs: [build-typescript, generate-api-docs, setup-jekyll]
if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
bundler-cache: true
working-directory: docs
- name: Build Jekyll site
run: bundle exec jekyll build --baseurl="/node-syslog"
working-directory: docs
- name: Add .nojekyll
run: |
touch docs/_site/.nojekyll
rm -f docs/_site/api/.nojekyll
working-directory: docs
- name: Verify build output
run: |
echo "📁 Generated files:"
find docs/_site -type f | head -20
echo ""
echo "📁 Total files: $(find docs/_site -type f | wc -l)"
echo "📁 Total directories: $(find docs/_site -type d | wc -l)"
# Check for essential files
if [ -f "docs/_site/index.html" ]; then
echo "✅ Main index.html found"
else
echo "❌ Main index.html missing"
exit 1
fi
if [ -f "docs/_site/_api/index.html" ]; then
echo "✅ API documentation found"
else
echo "⚠️ API documentation not found"
fi
working-directory: docs
- name: Deploy to GitHub Pages
id: deployment
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_site
publish_branch: gh-pages
keep_files: false
cname: node-syslog.schamane.de
- name: List deployed files (requires GH_TOKEN)
if: env.GH_TOKEN != ''
run: |
echo "📁 Files deployed to gh-pages:"
gh api repos/:owner/:repo/pages/build/latest | jq -r '.artifacts[].name' 2>/dev/null || echo "Using fallback listing..."
# Fallback listing
echo "📁 Available files in _site:"
find docs/_site -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.svg" | sort | head -10
echo "..."
echo "Total HTML files: $(find docs/_site -name "*.html" | wc -l)"
echo "Total CSS files: $(find docs/_site -name "*.css" | wc -l)"
echo "Total JS files: $(find docs/_site -name "*.js" | wc -l)"
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: List deployed files (fallback)
if: env.GH_TOKEN == ''
run: |
echo "📁 Files deployed to gh-pages:"
echo "📁 Available files in _site:"
find docs/_site -name "*.html" -o -name "*.css" -o -name "*.js" -o -name "*.svg" | sort | head -10
echo "..."
echo "Total HTML files: $(find docs/_site -name "*.html" | wc -l)"
echo "Total CSS files: $(find docs/_site -name "*.css" | wc -l)"
echo "Total JS files: $(find docs/_site -name "*.js" | wc -l)"
echo ""
echo "📖 Documentation available at: https://schamane.github.io/node-syslog/"
echo "📖 Custom domain: https://node-syslog.schamane.de/"