This document provides a comprehensive guide to the CI/CD pipeline implementation for Stellar Bridge Watch using GitHub Actions.
- Overview
- Architecture
- Workflows
- Setup Instructions
- Deployment Process
- Security
- Monitoring and Notifications
- Troubleshooting
The CI/CD pipeline automates the entire software delivery process from code commit to production deployment. It includes:
- ✅ Automated testing on every pull request
- ✅ Build verification for all packages (backend, frontend, contracts)
- ✅ Code quality and linting checks
- ✅ Security vulnerability scanning
- ✅ Docker image building and publishing
- ✅ Automated deployment to staging and production
- ✅ Release automation with artifact publishing
- ✅ Dependency update automation
- ✅ Test coverage reporting
┌─────────────────────────────────────────────────────────────────┐
│ Developer Push │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Pull Request Created │
└────────────────────────────┬────────────────────────────────────┘
│
┌────────────┴────────────┐
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ CI Workflow │ │ Code Quality │
│ - Backend Tests │ │ - ESLint │
│ - Frontend Build │ │ - Clippy │
│ - Contract Tests │ │ - Dependency Review │
│ - Docker Build │ └───────────────────────┘
└───────────┬───────────┘
│ ┌───────────────────────┐
└───────────────▶│ Security Scanning │
│ - NPM Audit │
│ - Cargo Audit │
│ - CodeQL │
│ - Trivy │
│ - Secret Scan │
└───────────────────────┘
│
▼
┌───────────────────────┐
│ PR Approved │
│ & Merged │
└──────────┬────────────┘
│
┌───────────────────┴───────────────────┐
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ Deploy to Staging │ │ Create Release │
│ (develop branch) │ │ (version tag) │
└───────────┬───────────┘ └───────────┬───────────┘
│ │
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ Smoke Tests │ │ Build Artifacts │
└───────────┬───────────┘ │ - Contracts │
│ │ - Docker Images │
▼ └───────────────────────┘
┌───────────────────────┐
│ Deploy to Production │
│ (main branch) │
│ [Requires Approval] │
└───────────────────────┘
Purpose: Continuous Integration for all code changes
Triggers:
- Push to
mainordevelopbranches - Pull requests to
mainordevelopbranches
Jobs:
- Sets up Node.js 20
- Starts PostgreSQL (TimescaleDB) and Redis services
- Installs dependencies
- Runs ESLint
- Builds TypeScript code
- Executes tests with coverage
- Uploads coverage to Codecov
- Sets up Node.js 20
- Installs dependencies
- Runs ESLint
- Performs TypeScript type checking
- Builds production bundle
- Runs tests with coverage
- Sets up Rust toolchain with wasm32 target
- Caches Cargo dependencies
- Checks code formatting with rustfmt
- Runs Clippy linter
- Builds contracts for wasm32-unknown-unknown
- Executes contract tests
- Uploads compiled WASM artifacts
- Verifies backend Docker image builds successfully
- Uses BuildKit cache for faster builds
- Aggregates all job results
- Required for branch protection
Environment Variables:
NODE_ENV: test
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: bridge_watch_test
POSTGRES_USER: bridge_watch
POSTGRES_PASSWORD: test_password
REDIS_HOST: localhost
REDIS_PORT: 6379Purpose: Automated deployment to staging and production
Triggers:
- Push to
main(production) ordevelop(staging) - Manual workflow dispatch with environment selection
Jobs:
- Builds Docker images for backend and frontend
- Tags images with:
- Branch name
- Git SHA
- Semantic version (if tagged)
- Pushes to GitHub Container Registry (ghcr.io)
- Uses layer caching for faster builds
- Runs on
developbranch pushes - Deploys to staging environment
- Executes smoke tests
- Sends deployment notifications
- Runs on
mainbranch pushes - Requires manual approval (environment protection)
- Deploys to production environment
- Executes smoke tests
- Sends deployment notifications
- Automatically triggered on deployment failure
- Reverts to previous stable version
Deployment Placeholders:
The workflow includes placeholder commands that need to be customized for your infrastructure:
# Kubernetes example
kubectl set image deployment/backend backend=${{ needs.build-and-push.outputs.backend-tag }}
# Docker Compose example
docker-compose pull && docker-compose up -d
# Cloud platform examples
aws ecs update-service --cluster my-cluster --service backend --force-new-deployment
gcloud run deploy backend --image ${{ needs.build-and-push.outputs.backend-tag }}
az containerapp update --name backend --image ${{ needs.build-and-push.outputs.backend-tag }}Purpose: Automated release creation and artifact publishing
Triggers:
- Push tags matching
v*.*.*(e.g., v1.0.0) - Manual workflow dispatch with version input
Jobs:
- Extracts version from tag or input
- Generates changelog from git commits
- Creates GitHub release (draft for pre-releases)
- Compiles Soroban contracts
- Creates tarball of WASM files
- Uploads to GitHub release
- Builds Docker images
- Tags with version and
latest - Pushes to GitHub Container Registry
- Currently disabled
- Can be enabled for publishing packages to NPM registry
- Sends notifications about release completion
Version Format:
- Stable:
v1.0.0,v2.1.3 - Pre-release:
v1.0.0-alpha.1,v1.0.0-beta.2,v1.0.0-rc.1
Purpose: Enforce code quality standards
Triggers:
- Pull requests
- Push to
mainordevelop
Jobs:
- Runs ESLint on TypeScript/JavaScript code
- Generates JSON report
- Uploads results as artifact
- Runs Clippy linter on Rust code
- Treats warnings as errors
- Generates JSON report
- Reviews dependency changes in PRs
- Fails on moderate or higher severity vulnerabilities
- Only runs on pull requests
- Aggregates all results
- Displays in GitHub Actions summary
Purpose: Identify and report security vulnerabilities
Triggers:
- Push to
mainordevelop - Pull requests
- Daily schedule at 2 AM UTC
Jobs:
- Scans Node.js dependencies
- Reports moderate and higher vulnerabilities
- Runs for backend and frontend
- Scans Rust dependencies
- Uses RustSec Advisory Database
- Reports known vulnerabilities
- Static code analysis for security issues
- Scans JavaScript and TypeScript
- Uploads results to GitHub Security tab
- Scans filesystem for vulnerabilities
- Checks for misconfigurations
- Reports critical and high severity issues
- Uploads SARIF results
- Detects accidentally committed secrets
- Uses TruffleHog OSS
- Scans entire git history
- Only reports verified secrets
- Aggregates all scan results
- Displays in GitHub Actions summary
Purpose: Keep dependencies up to date
Triggers:
- Weekly schedule (Monday 9 AM UTC)
- Manual workflow dispatch
Jobs:
- Updates Node.js dependencies
- Runs
npm audit fixfor security patches - Creates pull request with changes
- Updates Rust dependencies
- Creates pull request with changes
Automation:
- PRs are automatically labeled with
dependenciesandautomated - Branch is automatically deleted after merge
For cache strategy and invalidation details, see Build Cache Matrix.
Configure these secrets in Settings > Secrets and variables > Actions:
| Secret Name | Required | Description |
|---|---|---|
CODECOV_TOKEN |
Optional | Token for uploading test coverage to Codecov |
NPM_TOKEN |
Optional | NPM authentication token (if publishing packages) |
SLACK_WEBHOOK_URL |
Optional | Webhook URL for Slack notifications |
DISCORD_WEBHOOK_URL |
Optional | Webhook URL for Discord notifications |
Configure deployment environments in Settings > Environments:
- Click "New environment"
- Name:
staging - Environment URL:
https://staging.stellarbridgewatch.io - Protection rules: None (auto-deploy)
- Click "New environment"
- Name:
production - Environment URL:
https://stellarbridgewatch.io - Protection rules:
- ✅ Required reviewers (add team members)
- ✅ Wait timer: 5 minutes (optional)
- ✅ Deployment branches:
mainonly
Configure branch protection for main:
- Go to
Settings > Branches > Add rule - Branch name pattern:
main - Enable:
- ✅ Require a pull request before merging
- Required approvals: 1
- ✅ Require status checks to pass before merging
- Required checks:
CI Status CheckCode Quality SummarySecurity Summary
- Required checks:
- ✅ Require branches to be up to date before merging
- ✅ Require conversation resolution before merging
- ✅ Do not allow bypassing the above settings
- ✅ Restrict who can push to matching branches (optional)
- ✅ Require a pull request before merging
Repeat for develop branch with similar settings.
- Go to
Settings > Actions > General - Workflow permissions:
- ✅ Read and write permissions
- ✅ Allow GitHub Actions to create and approve pull requests
- Sign up at https://codecov.io
- Add your repository
- Copy the upload token
- Add as
CODECOV_TOKENsecret in GitHub
Update deployment commands in .github/workflows/deploy.yml based on your infrastructure:
# Example for Kubernetes
- name: Deploy to production
run: |
kubectl config use-context production
kubectl set image deployment/backend backend=${{ needs.build-and-push.outputs.backend-tag }}
kubectl set image deployment/frontend frontend=${{ needs.build-and-push.outputs.frontend-tag }}
kubectl rollout status deployment/backend
kubectl rollout status deployment/frontend- Create feature branch from
develop - Make changes and commit
- Open pull request to
develop - CI workflows run automatically
- After approval and merge:
- Docker images are built
- Deployed to staging automatically
- Smoke tests run
- Notifications sent
- Create pull request from
developtomain - CI workflows run automatically
- After approval and merge:
- Docker images are built
- Deployment waits for manual approval
- Reviewer approves in GitHub UI
- Deployed to production
- Smoke tests run
- Notifications sent
- Create hotfix branch from
main - Make critical fix
- Open pull request to
main - After approval and merge:
- Follows production deployment process
- Backport to
developif needed
- Ensure
mainbranch is stable - Create and push version tag:
git tag -a v1.0.0 -m "Release version 1.0.0" git push origin v1.0.0 - Release workflow runs automatically:
- Creates GitHub release
- Builds and uploads contract artifacts
- Publishes Docker images with version tags
- Sends notifications
-
Secrets Management
- Never commit secrets to repository
- Use GitHub Secrets for sensitive data
- Rotate secrets regularly
-
Dependency Security
- Review dependency update PRs promptly
- Monitor security advisories
- Keep dependencies up to date
-
Container Security
- Use official base images
- Scan images for vulnerabilities
- Keep base images updated
-
Access Control
- Limit who can approve production deployments
- Use branch protection rules
- Enable two-factor authentication
- On every PR: CodeQL, Trivy, Dependency Review
- Daily: Full security scan suite
- Weekly: Dependency updates
-
Security scan fails:
- Review the security report
- Assess severity and impact
- Create issue or fix immediately
- Update dependencies if needed
-
Secret detected:
- Rotate the compromised secret immediately
- Update in GitHub Secrets
- Review git history
- Consider rewriting history if needed
Monitor workflow status:
- GitHub Actions tab in repository
- Email notifications (configure in GitHub settings)
- Status badges in README
-
Create Slack webhook:
- Go to https://api.slack.com/messaging/webhooks
- Create new webhook for your channel
- Copy webhook URL
-
Add secret to GitHub:
- Go to
Settings > Secrets and variables > Actions - Add
SLACK_WEBHOOK_URLsecret
- Go to
-
Notifications are sent on:
- Deployment completion (success/failure)
- Release creation
- Security scan failures
-
Create Discord webhook:
- Go to Server Settings > Integrations > Webhooks
- Create webhook
- Copy webhook URL
-
Add secret to GitHub:
- Add
DISCORD_WEBHOOK_URLsecret
- Add
-
Update workflow notification steps to use Discord format
Track these metrics:
- Build success rate
- Average build time
- Deployment frequency
- Mean time to recovery (MTTR)
- Test coverage trends
- Security vulnerability trends
Symptoms:
Error: connect ECONNREFUSED 127.0.0.1:5432
Solution:
- Ensure service containers are healthy
- Check health check configuration
- Verify port mappings
- Add wait-for-it script if needed
Symptoms:
Error: no space left on device
Solution:
- name: Free disk space
run: |
docker system prune -af
df -hSymptoms:
Error: Failed to upload coverage
Solution:
- Verify
CODECOV_TOKENis set - Check coverage file path
- Ensure coverage is generated
- Use
continue-on-error: truefor non-blocking
Symptoms:
Error: authentication failed
Solution:
- Verify deployment credentials
- Check secret names match workflow
- Ensure secrets are not expired
- Test credentials manually
Symptoms:
- Workflow doesn't run on push/PR
Solution:
- Check branch names match trigger configuration
- Verify workflow file syntax (use YAML validator)
- Check if workflows are enabled in repository settings
- Review workflow permissions
Enable debug logging:
-
Add repository variable:
- Go to
Settings > Secrets and variables > Actions > Variables - Add
ACTIONS_STEP_DEBUG=true
- Go to
-
Re-run failed workflow
-
Review detailed logs
- Check GitHub Actions documentation
- Review workflow logs in Actions tab
- Search GitHub Community forums
- Open issue in repository
| Frequency | Task |
|---|---|
| Weekly | Review and merge dependency update PRs |
| Monthly | Review security scan results |
| Monthly | Update GitHub Actions versions |
| Quarterly | Review and optimize workflow performance |
| Quarterly | Update documentation |
| As needed | Update deployment scripts |
Check for outdated actions:
# List all actions used
grep -r "uses:" .github/workflows/ | cut -d: -f3 | sort -u
# Check for updates on GitHub MarketplaceUpdate actions to latest versions:
# Before
- uses: actions/checkout@v3
# After
- uses: actions/checkout@v4-
Use caching:
- uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
-
Parallelize jobs:
- Run independent jobs concurrently
- Use job dependencies only when necessary
-
Optimize Docker builds:
- Use multi-stage builds
- Leverage layer caching
- Minimize image size
-
Skip unnecessary runs:
on: push: paths-ignore: - "docs/**" - "**.md"
This CI/CD pipeline provides a robust, automated workflow for developing and deploying Stellar Bridge Watch. It ensures code quality, security, and reliability while enabling rapid iteration and deployment.
For questions or issues, please open an issue in the repository or contact the maintainers.