π GitHub Actions Deployment Workflow Guide
π Overviewβ
This is the current deployment guide for the API workflow and the shared release story referenced by service deployment docs.
Current promotion flow:
feature/*, fix/*, refactor/*, chore/*, hotfix/*
-> open PR to beta
beta
-> deploy beta
-> open PR to alpha
alpha
-> deploy alpha
-> open PR to main
main
-> deploy production
There is also an emergency production workflow for incidents that cannot wait for the normal promotion path.
ποΈ Workflow Architectureβ
Pipeline Stagesβ
| Stage | Purpose | Environment | URL Pattern |
|---|---|---|---|
| Beta | shared internal validation | beta | https://beta.api.{domain} |
| Alpha | staging / pre-production | alpha | https://alpha.api.{domain} |
| Production | live system | production | https://api.{domain} |
π― Workflow Triggersβ
Automatic Triggersβ
Push Eventsβ
on:
push:
branches:
- "feature/**" # build + open PR to beta
- "refactor/**" # build + open PR to beta
- "fix/**" # build + open PR to beta
- "chore/**" # build + open PR to beta
- "hotfix/**" # build + open PR to beta
- "staging/**" # build + open PR to alpha
- "beta" # deploy beta + open PR to alpha
- "alpha" # deploy alpha + open PR to main
- "main" # deploy production
Pull Request Eventsβ
on:
pull_request:
branches:
- "beta"
- "alpha"
- "main"
Merged PRs into beta or alpha are part of the deploy conditions for those target environments.
Manual Triggersβ
on:
workflow_dispatch:
inputs:
target_stage:
type: choice
options: [beta, alpha, production]
π§ Jobs & Workflow Stepsβ
Job 1: Build And Packageβ
Purpose: validate the repo and create the deployable artifact used by every standard deploy job.
build-and-test:
runs-on: ubuntu-latest
steps:
- Checkout repository
- Setup Node.js 20.10.0
- Install dependencies (npm ci)
- Run type checking
- Build TypeScript
- Assemble deployment bundle
- Upload deploy-package artifact
The standard workflow currently enforces type-check + build.
The test step is still commented out in api-deploy.yml, so do not describe the normal path as fully test-gated.
Job 2: Open Promotion PRsβ
Feature-style branches open a PR to beta.
staging/* branches open a PR directly to alpha when beta needs to be bypassed for controlled validation.
These PR jobs do not deploy by themselves. They prepare the branch promotion step that will trigger a deploy after merge or direct branch push.
Job 3: Deploy Beta / Alpha / Productionβ
The normal deploy jobs now use the same shared deploy action as the emergency workflow:
- workflow action:
.github/actions/deploy - artifact contract:
deploy-package/dist,deploy-package/package.json,deploy-package/package-lock.json - server runtime expectation: app starts from
dist/index.js
Environment triggers:
betabranch or manualtarget_stage=beta-> deploy betaalphabranch or manualtarget_stage=alpha-> deploy alphamainbranch or manualtarget_stage=production-> deploy production
Production also performs the version bump before deploying and runs under the GitHub production environment.
Version Bumping Logicβ
- Commit contains
[MAJOR]-> major version bump - Commit contains
[MINOR]-> minor version bump - Default -> patch version bump
π Required Secrets & Configurationβ
Repository Secretsβ
secrets:
DOMAIN_NAME: # Base domain (e.g., attunelogic.com)
SSH_HOST: # Deployment server hostname/IP
SSH_USER: # SSH username for deployment
SSH_PASS: # SSH password/key for deployment
SSH_PORT: # SSH port (usually 22)
GITHUB_TOKEN: # Automatic (for PR creation)
GitHub Environmentsβ
Configure in GitHub: Settings β Environments
beta: Beta environment configurationalpha: Alpha environment configurationproduction: Production environment (with protection rules)
Recommended Protection Rules:
- β Required reviewers for production
- β Wait timer for production deployments
- β Restrict to specific branches
π Custom Deploy Actionβ
The workflow uses a custom deploy action: .github/actions/deploy
Expected Interface:
inputs:
environment: # beta, alpha, production
domain: # Domain name
ssh_host: # Server hostname
ssh_user: # SSH username
ssh_pass: # SSH credentials
ssh_port: # SSH port
π¦ Deployment Bundle Contractβ
Current API deploys should be treated as a runnable Node app bundle, not a dist/ folder by itself.
Expected runtime bundle:
dist/package.jsonpackage-lock.json
Runtime expectation on server:
- app starts from
node dist/index.js - health checks verify the deployed app after startup
π¨ Emergency And Fallback Pathsβ
The API repo also includes an emergency workflow:
- workflow:
.github/workflows/emergency-deploy.yml - action used by emergency path:
.github/actions/deploy
Use the emergency path only for production incidents that cannot wait for normal promotion. It still builds the app, can run tests by default, and performs production health verification after deploy.
π Deployment Flow Examplesβ
Feature Development β Betaβ
- Developer pushes to
feature/new-security-feature - Workflow triggers
build-and-test+deploy-beta - Auto-deployment to beta environment
- Auto-PR created:
feature/new-security-featureβbeta - Testing on
https://beta.api.domain.com - Review & Merge PR when testing complete
Beta β Alpha Promotionβ
- Team merges feature PR into
betabranch - Workflow triggers
build-and-test+deploy-alpha - Auto-deployment to alpha environment
- Auto-PR created:
betaβalpha - Staging validation on
https://alpha.api.domain.com - Approve & Merge for production release
Alpha β Production Releaseβ
- Release Manager merges alpha PR into
alphabranch - Workflow triggers
build-and-test+deploy-production - Version bump based on commit message
- Auto-deployment to production environment
- Auto-PR created:
alphaβmain(with version tag) - Merge to keep
mainin sync with production
π Branch Strategy & GitOpsβ
Branch Hierarchyβ
main (production sync)
βββ alpha (production candidate)
β βββ beta (staging)
β β βββ feature/security-features
β β βββ feature/ui-improvements
β β βββ feature/bug-fixes
GitOps Principlesβ
- π Declarative: Infrastructure as code
- π Version Controlled: All changes tracked in Git
- π€ Automated: No manual deployment steps
- π‘οΈ Auditable: Complete deployment history
- π Secure: Environment-based access controls
π Monitoring & Validationβ
Health Check Endpointsβ
Each deployment includes automatic health check validation:
# Beta Environment
GET https://beta.api.{domain}/health
# Alpha Environment
GET https://alpha.api.{domain}/health
# Production Environment
GET https://api.{domain}/health
Expected Response:
{
"status": "ok",
"timestamp": "2024-01-15T10:30:00.000Z",
"uptime": 1234567,
"environment": "beta|alpha|production",
"version": "2.9.0"
}
Deployment Verificationβ
- β HTTP 200 response from health endpoint
- β Correct environment in response
- β Service uptime > 0
- β Expected version number
β οΈ Best Practices & Guidelinesβ
Commit Message Conventionsβ
# Patch version bump (default)
git commit -m "fix: resolve rate limiting bug"
# Minor version bump
git commit -m "feat: add brute force protection [MINOR]"
# Major version bump
git commit -m "feat!: breaking API changes [MAJOR]"
Branch Naming Conventionsβ
# Feature development
feature/security-rate-limiting
feature/ui-dashboard-improvements
feature/user-management-system
# Code refactoring
refactor/optimize-database-queries
refactor/restructure-auth-middleware
refactor/cleanup-legacy-code
# Bug fixes
fix/user-authentication-bug
fix/database-connection-issue
fix/api-response-formatting
# Staging branches (service, optional direct-to-Alpha)
staging/critical-security-patch
staging/quick-alpha-validation
For critical, time-sensitive UI fixes in the AttuneLogic Service, prefer a
staging/*branch that deploys directly to Alpha over introducing a separatehotfix/*naming scheme. The API workflow itself still follows the standard feature β beta β alpha β production promotion path.
Environment Usage Guidelinesβ
Beta Environment π§ͺβ
- Purpose: Feature testing and integration
- Data: Test data only
- Access: Development team
- Stability: May be unstable during active development
Alpha Environment π―β
- Purpose: Staging and user acceptance testing
- Data: Production-like test data
- Access: Extended team, stakeholders
- Stability: Should be stable and production-ready
Production Environment πβ
- Purpose: Live customer-facing system
- Data: Real customer data
- Access: Restricted, monitored
- Stability: Must be highly available and stable
π¨ Troubleshootingβ
Common Issuesβ
Build Failuresβ
# Check these locally before pushing:
npm run type-check # TypeScript errors
npm run build # Compilation issues
npm run test:safe # Test failures
Deployment Failuresβ
- β Verify SSH credentials in repository secrets
- β Check server accessibility and ports
- β Validate environment configurations
- β Review deploy action logs
PR Creation Failuresβ
- β
Ensure
GITHUB_TOKENhas proper permissions - β Check branch protection rules
- β Verify repository permissions for actions
Manual Interventionβ
Emergency Production Deploymentβ
- Use workflow_dispatch with
productiontarget - Monitor deployment carefully
- Create manual PR for
alphaβmainsync
Rollback Procedureβ
- Revert commits in
alphabranch - Trigger automatic deployment to production
- Create hotfix branch for proper fix
π Workflow Metrics & Analyticsβ
Deployment Frequencyβ
- Beta: Multiple times per day
- Alpha: Daily to weekly
- Production: Weekly to monthly
Success Rate Targetsβ
- Build Success: >95%
- Beta Deployment: >98%
- Alpha Deployment: >99%
- Production Deployment: >99.9%
Performance Metricsβ
- Build Time: <10 minutes
- Deployment Time: <5 minutes per environment
- Health Check Response: <30 seconds
π§ Customization & Extensionsβ
Adding New Environmentsβ
- Create new environment in GitHub settings
- Add new job in workflow file
- Configure secrets and protection rules
- Update custom deploy action
Custom Validation Stepsβ
- name: Security Scan
run: npm audit --audit-level high
- name: Performance Test
run: npm run test:performance
- name: Integration Test
run: npm run test:integration
Notification Integrationβ
- name: Slack Notification
if: failure()
uses: 8398a7/action-slack@v3
with:
status: failure
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
π Related Documentationβ
- Security Implementation Guide
- Multi-Industry Testing Guide (Coming Soon)
- Deployment Readiness Report (Coming Soon)
- GitHub Actions Deploy Action (Coming Soon)
π― Summaryβ
This workflow provides:
β
Automated 3-stage deployment pipeline
β
Built-in testing and validation
β
Automatic PR creation and tracking
β
Semantic versioning for releases
β
Environment-specific configurations
β
Security and access controls
β
Health checks and monitoring
β
GitOps best practices
The workflow ensures safe, reliable deployments while maintaining fast development velocity and complete audit trails for your multi-tenant, multi-industry SaaS platform. π