Skip to content

Posts Refeactor

Posts Refeactor #13

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 ==="
# Remove CNAME file for previews to avoid routing conflicts
rm -f CNAME
# Build Jekyll site - staging posts will be included as a collection
bundle exec jekyll build --config _config.yml,_config_preview.yml
# Verify build succeeded
if [ ! -d "_site" ] || [ -z "$(ls -A _site 2>/dev/null)" ]; then
echo "ERROR: Jekyll build failed or created empty _site directory"
exit 1
fi
echo "Build completed successfully"
echo "Files built: $(find _site -type f | wc -l)"
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/"