# Example Deployment Workflow
# Copy this file to deploy.yml and customize for your deployment target
# Remove .example extension to activate
name: Deploy
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch: # Allow manual deployment
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
deploy-staging:
name: Deploy to Staging
runs-on: ubuntu-latest
if: github.ref_type == 'tag' || github.event_name == 'workflow_dispatch'
environment:
name: staging
url: https://staging.example.com
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to staging server
run: |
echo "Deploying to staging..."
# Example: SSH deployment
# ssh user@staging-server "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}"
# ssh user@staging-server "docker-compose up -d"
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
needs: deploy-staging
if: github.ref_type == 'tag'
environment:
name: production
url: https://api.example.com
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Deploy to production
run: |
echo "Deploying to production..."
# Example: Kubernetes deployment
# kubectl set image deployment/main_patient_index-server mpi-server=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
- name: Verify deployment
run: |
echo "Verifying deployment..."
# curl -f https://api.example.com/api/v1/health || exit 1
- name: Notify deployment
if: success()
run: |
echo "Deployment successful!"
# Send notification to Slack, email, etc.
- name: Rollback on failure
if: failure()
run: |
echo "Deployment failed, rolling back..."
# kubectl rollout undo deployment/main_patient_index-server
# Alternative deployment examples:
# AWS ECS Deployment:
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: us-east-1
#
# - name: Deploy to ECS
# run: |
# aws ecs update-service --cluster mpi-cluster --service mpi-service --force-new-deployment
# Docker Swarm Deployment:
# - name: Deploy to Swarm
# run: |
# docker stack deploy -c docker-compose.production.yml mpi
# Ansible Deployment:
# - name: Run Ansible playbook
# run: |
# ansible-playbook -i inventory/production deploy.yml --extra-vars "version=${{ github.ref_name }}"