This document describes the automated CI/CD pipeline for the Soroban Cookbook project.
The CI/CD pipeline ensures code quality, consistency, and reliable deployments through automated checks and deployments. The pipeline is implemented using GitHub Actions and consists of two main workflows:
- CI (Continuous Integration) - Runs on pull requests and pushes to validate code quality
- CD (Continuous Deployment) - Deploys documentation to GitHub Pages after CI passes
The CI workflow runs automatically on:
- Pull requests to
mainbranch - Pushes to
mainbranch - Manual trigger via
workflow_dispatch
Validates code formatting and linting standards.
Steps:
- Checkout code
- Setup Bun package manager
- Cache Bun dependencies
- Install dependencies with frozen lockfile
- Check formatting with Prettier
- Lint with ESLint (max warnings: 0)
Failure Conditions:
- Code doesn't match Prettier formatting
- ESLint finds any linting issues
Local Equivalent:
cd documentation
bun install --frozen-lockfile
bun run format:check
bun run lintValidates TypeScript compilation without errors.
Steps:
- Checkout code
- Setup Bun
- Cache Bun dependencies
- Install dependencies
- Run TypeScript compiler
Failure Conditions:
- TypeScript compilation errors
Local Equivalent:
cd documentation
bun install --frozen-lockfile
bun run typecheckBuilds the Docusaurus documentation site.
Steps:
- Checkout code
- Setup Bun
- Cache Bun dependencies
- Cache build output
- Install dependencies
- Build documentation
- Verify build artifact (check for build/ directory and index.html)
- Upload build artifact for 5 days
Failure Conditions:
- Build fails
- Build directory not created
- index.html not found in build
Local Equivalent:
cd documentation
bun install --frozen-lockfile
bun run buildValidates deployment configuration and workflow syntax.
Steps:
- Checkout code
- Setup Bun
- Check bun.lock exists
- Cache Bun dependencies
- Install dependencies
- Validate workflow syntax (checks for required GitHub Actions)
Failure Conditions:
- bun.lock missing
- Required GitHub Actions missing from deploy workflow
Aggregates results from all CI jobs and reports overall status.
Runs After: All other jobs (lint-format, typecheck, build-docs, validate-deployment)
Failure Conditions:
- Any upstream job fails
The CD workflow runs automatically on:
- Pushes to
mainbranch - Manual trigger via
workflow_dispatch
Builds the documentation site for deployment.
Steps:
- Checkout code
- Setup Bun
- Cache Bun dependencies
- Install dependencies
- Build documentation
- Upload artifact to GitHub Pages
Deploys the built documentation to GitHub Pages.
Steps:
- Configure GitHub Pages environment
- Deploy artifact to GitHub Pages
- Output deployment summary with URL
Environment: github-pages
Output: Deployment URL available in workflow run details
The pipeline implements multi-level caching to optimize runtime:
- Key:
bun-${{ hashFiles('documentation/bun.lock') }} - Path:
~/.bun/install/cache - Restore Keys:
bun-(fallback to any previous cache) - Impact: Reduces dependency installation time by ~60-80%
- Key:
build-${{ github.sha }} - Path:
documentation/build - Restore Keys:
build-(fallback to any previous build) - Impact: Allows reuse of build artifacts across jobs
- Group:
ci-${{ github.ref }} - Behavior: Cancels in-progress runs when new commits are pushed
- Purpose: Prevents resource waste on outdated checks
- Group:
pages - Behavior: Does not cancel in-progress deployments
- Purpose: Ensures deployments complete without interruption
contents: read- Read repository contentschecks: write- Write check resultspull-requests: write- Write PR comments
contents: read- Read repository contentspages: write- Write to GitHub Pagesid-token: write- OIDC token for GitHub Pages
Before pushing, run these commands to catch issues early:
cd documentation
# Install dependencies
bun install --frozen-lockfile
# Format check
bun run format:check
# Lint check
bun run lint
# TypeScript check
bun run typecheck
# Build check
bun run build# Fix formatting
bun run format
# Fix linting issues (where possible)
bun run lint:fixcd documentation
bun install --frozen-lockfile
bun run format:check && \
bun run lint && \
bun run typecheck && \
bun run buildTo enforce CI checks, configure branch protection on main:
- Go to Settings → Branches
- Add rule for
mainbranch - Enable "Require status checks to pass before merging"
- Select required checks:
CI / Lint & FormatCI / TypeScript CheckCI / Build DocumentationCI / Validate DeploymentCI / CI Summary
Error: Prettier check failed
Solution:
cd documentation
bun run format
git add .
git commit -m "style: format code"Error: ESLint found issues
Solution:
cd documentation
bun run lint:fix
git add .
git commit -m "style: fix linting issues"Error: Type errors found
Solution:
- Review the error messages in the workflow logs
- Fix type issues in the source code
- Run
bun run typechecklocally to verify - Commit and push
Error: Build failed
Solution:
- Check workflow logs for specific error
- Run
bun run buildlocally to reproduce - Fix the issue (usually broken links or syntax errors)
- Verify with
bun run buildlocally - Commit and push
Error: Pages is not enabled
Solution:
- Go to Settings → Pages
- Set Source to "GitHub Actions"
- Retry deployment
Error: Insufficient permissions
Solution:
- Go to Settings → Actions → General
- Set Workflow permissions to "Read and write permissions"
- Retry deployment
Typical workflow runtimes (with caching):
| Job | Time |
|---|---|
| Lint & Format | ~30-45s |
| TypeScript Check | ~30-45s |
| Build Documentation | ~1-2m |
| Validate Deployment | ~30-45s |
| Total CI | ~3-4m |
| CD Build | ~1-2m |
| CD Deploy | ~30-60s |
First run (without cache) may take 2-3x longer.
- Add PR preview deployments
- Add Lighthouse performance audits
- Add deployment notifications
- Add automated rollback on deployment failure
- Add security scanning (SAST/dependency checks)
- Add artifact retention policies
- Add deployment approval gates for production
- DEPLOYMENT.md - Deployment configuration guide
- CONTRIBUTING.md - Contribution guidelines
- GitHub Actions Documentation