Automated CI/CD workflow for syncing, testing, and deploying applications from a stable branch to production.
This repository contains a GitHub Actions workflow that automates the process of:
- Detecting changes between stable and production branches
- Testing and building the stable branch
- Running release processes with semantic versioning
- Deploying to production environments
The main workflow runs automatically on a weekly schedule:
- Day: Wednesday
- Time: 8:30 PM UTC / Thursday 2:00 AM SLT
- Cron:
30 20 * * 3
Manual triggers are also supported via workflow_dispatch.
Detects if there are new commits in the stable branch that need syncing to production.
- Checks out the
stablebranch - Sets up Node.js environment (v20)
- Installs dependencies with
npm ci - Auto-detects and runs test suite (if available)
- Builds the application with
npm run build
- Merges
stablebranch intoproductionusing a merge commit (--no-ff) - Pushes the merge to the remote repository
- Saves the previous production commit for potential rollback
- Re-tests and rebuilds on the
productionbranch - Runs the same test and build steps to ensure quality post-merge
- Runs semantic-release to:
- Analyze commits and determine version bump
- Generate changelog
- Create GitHub release
- Commit and tag version updates
- Push updates back to
productionbranch
- Checks out the
productionbranch - Placeholder implementation - customize with your deployment logic:
- Can use AWS CLI, kubectl, Docker, rsync, SCP, etc.
- Requires
DEPLOY_TARGETandDEPLOY_TOKENsecrets
- Runs smoke tests on the deployed environment
- Automatically triggered if any previous job fails
- Reverts
productionbranch to the pre-merge commit - Force pushes to remote to undo any changes
Configure release behavior in .releaserc.json:
- Semantic versioning rules
- Changelog generation
- Git commit and tag settings
Main workflow file: .github/workflows/weekly-production-sync.yml
- Node.js 20+
- npm
- GitHub repository with
stableandproductionbranches - Appropriate GitHub Actions permissions for branch operations
The workflow runs automatically every Wednesday at 8:30 PM UTC (Thursday 2:00 AM SLT).
To manually trigger the workflow:
- Go to Actions tab in GitHub
- Select Weekly Sync, Test, Release & Deploy
- Click Run workflow
Configure the following secrets in GitHub for deployment:
DEPLOY_TARGET: The target environment/endpoint for deploymentDEPLOY_TOKEN: Authentication token for deployment accessGITHUB_TOKEN: Automatically provided by GitHub Actions for semantic-release
The deployment step (job #6) is a template that requires customization for your specific platform:
Replace the deployment logic with your platform:
- AWS: AWS CLI commands (CloudFormation, Lambda, ECS, etc.)
- Kubernetes:
kubectl applycommands - Docker:
docker compose upor Docker image push/pull - Servers: SSH commands, rsync, SCP, etc.
Smoke Test Configuration: Update the health check URL in the smoke test step to match your production endpoint.
- Workflow fails at check-changes: No new commits in
stablebranch - nothing to deploy - Tests failing: Ensure all tests pass locally before pushing to
stable - Merge conflicts: Resolve conflicts between
stableandproductionmanually if needed - Deployment fails: Verify
DEPLOY_TARGETandDEPLOY_TOKENsecrets are set correctly - Rollback triggered: Check the workflow logs to identify which job failed and resolve the issue
When contributing:
- Work on feature branches
- Merge to
stablewhen ready for testing - The workflow handles promotion to
productionautomatically