Skip to content

Posts Refeactor

Posts Refeactor #14

Workflow file for this run

name: Deploy Staging Preview
on:
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch: # Allow manual trigger
permissions:
contents: write
concurrency: staging-preview
jobs:
deploy-staging:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'
bundler-cache: true
- name: Show staging content
run: |
echo "=== Staging content ==="
echo "Staging posts:"
find staging/ -name "*.md" -not -name "README.md" -not -name "index.md" | sort || echo " (none)"
echo "Published posts:"
ls -1 _posts/*.md 2>/dev/null | head -5 || echo " (none)"
- name: Build Jekyll site with staging
run: |
echo "=== Building Jekyll site with staging ==="
# Show what files are available to Jekyll
echo "=== Available content ==="
echo "Posts in _posts/:"
ls -la _posts/ 2>/dev/null || echo "No _posts directory"
echo "Posts in staging/:"
ls -la staging/ 2>/dev/null || echo "No staging directory"
echo "Index files:"
ls -la *.html *.md 2>/dev/null || echo "No index files"
# Show Jekyll configs
echo "=== Jekyll Configuration ==="
echo "Main config exists: $(test -f _config.yml && echo 'YES' || echo 'NO')"
echo "Preview config exists: $(test -f _config_preview.yml && echo 'YES' || echo 'NO')"
# Remove CNAME file for previews to avoid routing conflicts
rm -f CNAME
# Build Jekyll site with maximum verbosity
echo "=== Running Jekyll Build ==="
bundle exec jekyll build --config _config.yml,_config_preview.yml --verbose --trace
# Check build results in detail
echo "=== Build Results ==="
if [ -d "_site" ]; then
echo "_site directory exists"
echo "Contents of _site/:"
find _site -type f -exec ls -la {} \; 2>/dev/null || echo "No files in _site"
echo "Total files: $(find _site -type f 2>/dev/null | wc -l)"
else
echo "ERROR: _site directory does not exist!"
exit 1
fi
env:
JEKYLL_ENV: production
- name: Deploy staging site
run: |
echo "=== Deploying staging site ==="
# Switch to gh-pages branch
git fetch origin gh-pages:gh-pages || git checkout --orphan gh-pages
git checkout gh-pages
# Clear all content and deploy full site to root
rm -rf * 2>/dev/null || true
rm -rf .*/ 2>/dev/null || true
# Copy built site to root of gh-pages
cp -r _site/* ./
# Commit and push the staging site
git add -A
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git commit -m "Deploy staging preview from PR #${{ github.event.number }}" || exit 0
git push origin gh-pages
echo "=== Staging deployment complete ==="
echo "Preview URL: https://devnomadic.github.io/"