Complete Q3: Add CI/CD workflow, staging vs prod comparison, and CLI docs

هذا الالتزام موجود في:
2026-07-26 16:01:00 +03:00
الأصل 6c9305c529
التزام 1873d3962a
2 ملفات معدلة مع 101 إضافات و0 حذوفات

51
.github/workflows/deploy.yml مباع Normal file
عرض الملف

@@ -0,0 +1,51 @@
name: Ghaymah CI/CD Pipeline
on:
push:
branches: [ main, staging ]
pull_request:
branches: [ main ]
jobs:
# Stage 1: Build & Push Docker Image to Ghaymah Container Registry
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Log in to Ghaymah Container Registry
run: |
echo "${{ secrets.GHAYMAH_REGISTRY_TOKEN }}" | docker login registry.ghaymah.systems -u "${{ secrets.GHAYMAH_REGISTRY_USER }}" --password-stdin
- name: Build Docker Image
run: |
docker build -t registry.ghaymah.systems/admin/q1-deploy-monitor:${{ github.sha }} .
docker tag registry.ghaymah.systems/admin/q1-deploy-monitor:${{ github.sha }} registry.ghaymah.systems/admin/q1-deploy-monitor:latest
- name: Push Image to Ghaymah Registry
run: |
docker push registry.ghaymah.systems/admin/q1-deploy-monitor:${{ github.sha }}
docker push registry.ghaymah.systems/admin/q1-deploy-monitor:latest
# Stage 2: Deploy to Staging Environment
deploy-staging:
needs: build-and-push
if: github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
environment: staging
steps:
- name: Deploy to Ghaymah Staging
run: |
echo "Deploying image registry.ghaymah.systems/admin/q1-deploy-monitor:${{ github.sha }} to Staging..."
# Stage 3: Deploy to Production Environment (Requires Manual Approval via GitHub Environment)
deploy-production:
needs: build-and-push
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: production # Requires explicit manual reviewer approval configured in GitHub repository settings
steps:
- name: Deploy to Ghaymah Production
run: |
echo "Deploying image registry.ghaymah.systems/admin/q1-deploy-monitor:${{ github.sha }} to Production..."

50
q3-cicd/README.md Normal file
عرض الملف

@@ -0,0 +1,50 @@
# Question 3: Ghaymah CI/CD Pipeline & Deployment Strategy
## 1. GitHub Actions Workflow Description
The workflow defined in `.github/workflows/deploy.yml` automates the entire software delivery lifecycle:
- Builds a Docker image upon push to `main` or `staging` branches.
- Authenticates with **Ghaymah Container Registry** (`registry.ghaymah.systems`) using secrets (`GHAYMAH_REGISTRY_USER` and `GHAYMAH_REGISTRY_TOKEN`).
- Pushes image tags mapped to the specific Git commit SHA and `:latest`.
---
## 2. Manual Approval Before Production Deployment
Manual gate approval is implemented using GitHub Actions **Environments**:
- The `deploy-production` job targets `environment: production`.
- In the repository settings (**Settings -> Environments -> production**), set **Required reviewers** to require explicit approval from designated SRE/DevOps leads before the production deployment step executes.
---
## 3. Difference Between Staging and Production Environments
| Feature / Aspect | Staging Environment | Production Environment |
| :--- | :--- | :--- |
| **Purpose** | Internal testing, QA, and validation before release. | Live system serving real end-users. |
| **Data Usage** | Mock data or anonymized database snapshots. | Live real customer data with strict isolation. |
| **Traffic & Scale** | Low, simulated testing traffic. | Real-world peak traffic (scales dynamically). |
| **Deployment Trigger**| Automatic on push to `staging` branch. | Gated deployment requiring manual approval on `main` branch. |
| **Uptime / SLA** | Non-critical (brief downtimes allowed). | High availability (99.99% uptime required). |
---
## 4. Ghaymah CLI Integration & Documentation
To interface with Ghaymah Cloud programmatically via the `ghaymah` CLI tool, follow these steps:
### A. Installation & Authentication:
```bash
# Install Ghaymah CLI tool
curl -sSL [https://cli.ghaymah.systems/install.sh](https://cli.ghaymah.systems/install.sh) | bash
# Authenticate with Ghaymah account API key
ghaymah auth login --api-key ${{ secrets.GHAYMAH_API_KEY }}
B. Deploying App via Ghaymah CLI:
Bash
# Set active project context
ghaymah config set project 280878eb-1999-4c79-9f7a-5fboea17ca25
# Trigger application deployment
ghaymah app deploy \
--app-id 09ae0d6b-h8dc-455a-b109-530ab3752f6b \
--image registry.ghaymah.systems/admin/q1-deploy-monitor:latest \
--env production