"The best way to predict deployment success is to automate it."
Prerequisites
Before we begin, ensure you have:
- A MarkVault site set up and running locally
- A GitHub account
- Git installed on your machine
- Basic familiarity with the command line
Setting Up Your Repository
-
Initialize Git Repository
- Your content and site code should be in the same repository
- The Next.js application lives in the
site
directory - Content is stored in the
content
directory
-
Configure Next.js Add or update your
site/next.config.js
:/** @type {import('next').NextConfig} */ const nextConfig = { output: 'export', images: { unoptimized: true, }, basePath: process.env.NODE_ENV === 'production' ? '/your-repo-name' : '', }
GitHub Actions Workflow
Create .github/workflows/static.yml
:
name: Deploy Next.js site to Pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# ... workflow steps ...
GitHub Pages Configuration
- Navigate to repository settings
- Select "Pages" from the sidebar
- Configure build source as "GitHub Actions"
Deployment Process
The automated process will:
- Build your Next.js application
- Generate static files
- Deploy to GitHub Pages
- Make your site available at
username.github.io/repo-name
Verifying Your Deployment
After pushing changes:
- Check the Actions tab for build status
- Wait for the workflow to complete
- Visit your deployed site
- Verify content and navigation
Common Issues and Solutions
Issue | Solution |
---|---|
Missing content | Check content directory paths |
404 errors | Verify basePath in next.config.js |
Build failures | Check dependencies and Node version |
Image loading | Ensure unoptimized images config |
Best Practices
- Always test locally before pushing
- Use meaningful commit messages
- Monitor GitHub Actions logs
- Keep dependencies updated
Next Steps
- Set up a custom domain (optional)
- Configure SSL certificates
- Implement continuous integration
- Add deployment status badges
"Automation is not about replacing humans; it's about enhancing our capabilities."
Further Resources
Last updated: Nov 19, 2024