Complete GitHub Actions automation for PatchPath AI with Azure deployment.
Three automated workflows handle testing, building, and deployment:
- ci-cd.yml - Main pipeline (test → build → deploy)
- pr-check.yml - Pull request validation
- deploy-manual.yml - Manual deployment trigger
Triggers:
- Push to
mainbranch - Push to
developbranch - Pull requests to
main - Manual trigger
Jobs:
✓ Checkout code
✓ Setup Node.js 20
✓ Install dependencies (npm ci)
✓ Run ESLint
✓ TypeScript type checking
✓ Build applicationDuration: ~3-5 minutes
✓ Setup Docker Buildx
✓ Login to Azure Container Registry
✓ Extract image metadata
✓ Build multi-stage Docker image
✓ Push to ACR with tags:
- main-<sha>
- latest (on main branch)
✓ Layer caching for faster buildsDuration: ~5-10 minutes (first), ~2-3 minutes (cached)
Image tags created:
patchpathregistry.azurecr.io/patchpath-ai:latestpatchpathregistry.azurecr.io/patchpath-ai:main-abc1234
✓ Azure login
✓ Deploy to Container Apps (ready when #20 complete)
✓ Deployment summaryNote: Deployment commands ready, waiting for Azure Container App creation (Issue #20)
✓ Login to ACR
✓ Run Trivy vulnerability scanner
✓ Upload results to GitHub Security tab
✓ Security summaryDuration: ~2-3 minutes
Triggers:
- Pull requests to
mainordevelop
Jobs:
✓ Lint code
✓ Type check
✓ Build verification
✓ Docker build test (deps stage only)Duration: ~2-4 minutes
Purpose: Fast feedback for contributors without full Docker build
Triggers:
- Manual trigger via GitHub Actions UI
Inputs:
environment: production | stagingimage-tag: Docker tag to deploy (default: latest)
Use cases:
- Rollback to previous version
- Deploy specific commit
- Staging environment testing
- Emergency hotfix deployment
Configure in: Repository Settings → Secrets and variables → Actions
AZURE_REGISTRY_USERNAME=patchpathregistry
AZURE_REGISTRY_PASSWORD=<from Azure>
AZURE_REGISTRY_LOGIN_SERVER=patchpathregistry.azurecr.ioAZURE_CREDENTIALS=<JSON service principal>Generate Azure credentials:
az ad sp create-for-rbac \
--name "github-actions-patchpath" \
--role contributor \
--scopes /subscriptions/<subscription-id>/resourceGroups/patchpath-rg \
--sdk-authCopy the JSON output to AZURE_CREDENTIALS secret.
AZURE_COSMOS_CONNECTION_STRING=<from Azure>
ANTHROPIC_API_KEY=<from Anthropic>
CLERK_SECRET_KEY=<from Clerk>
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=<from Clerk>- Actions tab: https://github.com//patchpath-ai/actions
- Per commit: Click ✓ or ✗ next to commit in GitHub
Each workflow creates a markdown summary with:
- Build artifacts
- Image tags and digests
- Deployment status
- Security scan results
GitHub notifications for:
- ✅ Workflow success
- ❌ Workflow failure
- 🔒 Security vulnerabilities
# Make changes
git checkout -b feature/my-feature
git commit -m "Add awesome feature"
git push origin feature/my-feature
# Create PR → pr-check.yml runs
# Merge to main → ci-cd.yml runs
# Automatically: test → build → push → deploy- Go to Actions tab
- Select Manual Deployment
- Click Run workflow
- Choose:
- Environment: production
- Image tag: latest (or specific tag)
- Click Run workflow
# Find image tag from previous build
# Example: main-abc1234
# Use Manual Deployment workflow with:
# - environment: production
# - image-tag: main-abc1234# Find previous working image tag
# Use Manual Deployment workflow with old tagCause: package-lock.json out of sync
Fix:
npm install
git add package-lock.json
git commit -m "Update package-lock.json"
git pushCause: Cache corruption
Fix: Clear cache manually
# In workflow, add:
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=maxOr disable caching temporarily:
# Remove cache-from and cache-to linesCause: Expired or incorrect credentials
Fix:
# Get new credentials
az acr credential show --name patchpathregistry
# Update secrets in GitHub:
# AZURE_REGISTRY_USERNAME
# AZURE_REGISTRY_PASSWORDExpected: Issue #20 not complete yet
Fix: Complete Azure Container Apps setup first
Cause: Critical vulnerabilities found
Fix:
- Check Security tab for details
- Update vulnerable dependencies:
npm audit fix
- Rebuild and push
Check:
- GitHub Actions enabled? (Settings → Actions)
- Quota exceeded? (Free tier: 2000 min/month)
- Branch protection rules blocking?
- ✅ npm ci caching (~30s faster)
- ✅ Docker layer caching (~3-5 min faster)
- ✅ Multi-stage builds (smaller images)
- ✅ Parallel job execution
- ✅ Skip deployment on PR (only test)
- ✅ Conditional jobs (only deploy on main)
- ✅ Efficient Docker caching
- ✅ Free tier friendly (~50 min per push)
Estimated runtime per push to main:
Test & Lint: 3-5 min
Build & Push: 5-10 min (first) / 2-3 min (cached)
Security Scan: 2-3 min
Deploy: 1-2 min
------------------------
Total: ~12-20 min (first) / ~8-12 min (cached)
-
Update
ci-cd.ymldeploy job:- name: Deploy to Azure Container Apps run: | az containerapp update \ --name patchpath-app \ --resource-group patchpath-rg \ --image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
-
Configure environment variables in Container App:
az containerapp update \ --name patchpath-app \ --resource-group patchpath-rg \ --set-env-vars \ AZURE_COSMOS_CONNECTION_STRING=secretref:cosmos-connection \ ANTHROPIC_API_KEY=secretref:anthropic-key -
Test full pipeline:
git commit --allow-empty -m "Test CI/CD pipeline" git push origin main
- GitHub Actions tab: Workflow history
- Azure Portal: Container App logs
- Security tab: Vulnerability reports
- GitHub Actions Documentation
- Azure Container Apps CI/CD
- Docker Build Push Action
- Trivy Security Scanner
Before enabling CI/CD:
- Azure Container Registry created (Issue #3)
- Docker configuration complete (Issue #19)
- GitHub secrets configured
- Azure Container App created (Issue #20)
- Test manual deployment
- Monitor first automatic deployment
- Verify health checks pass