diff --git a/q3-cicd/README.md b/q3-cicd/README.md new file mode 100644 index 0000000..dbee065 --- /dev/null +++ b/q3-cicd/README.md @@ -0,0 +1,47 @@ +# CI/CD Pipeline Documentation + +## 1. Staging vs. Production Environments + +In the Software Development Life Cycle (SDLC) and DevOps practices, environments are strictly separated to ensure software quality and stability before reaching the end-user: + +* **Staging Environment:** + * This is an exact replica (clone) of the production environment, sharing the same configurations, database schemas, and network topology. + * **Purpose:** It acts as the final testing ground for Quality Assurance (QA), Integration Testing, and User Acceptance Testing (UAT) to catch bugs under real-world conditions. + * **Access & Impact:** Restricted to the development team, QA engineers, and stakeholders. If the system crashes here, real users are not affected. + +* **Production Environment:** + * This is the live, public-facing environment serving actual end-users and handling real data. + * **Purpose:** To deliver the application with maximum stability, security, and High Availability (HA). + * **Access & Impact:** Strictly controlled. Deploying to production is a highly sensitive operation that requires passing all automated tests in Staging and mandates a **Manual Approval** step in our CI/CD pipeline to prevent catastrophic failures. + +--- +# Ghaymah CLI Integration Guide + +To control deployments and monitor environments directly from the terminal (or integrate them programmatically into CI/CD pipelines), developers and SREs use the `ghaymah CLI`. + +## Step 1: Installation +Install the CLI tool on the local machine or CI build runners: +```bash +curl -sL [https://cli.ghaymah.systems/install](https://cli.ghaymah.systems/install) | bash +``` + +## Step 2: Authentication +To link the CLI with your Ghaymah account, you must authenticate either interactively or via an API token: +# Interactive login (for developers) +ghaymah login + +# Automated login using a Token (for GitHub Actions/Pipelines) +ghaymah login --token + +## Step 3: Project Configuration +Link your local workspace to the remote project hosted on the Ghaymah platform: +# Link the project using its unique Project ID +ghaymah project link --id + +## Step 4: Execution & Monitoring +Once configured, engineers can trigger deployments and monitor container health directly from the terminal: +# Trigger a new deployment +ghaymah app deploy + +# Stream live container logs for troubleshooting +ghaymah logs tail --app q1-sre-api diff --git a/q3-cicd/workflow.yml b/q3-cicd/workflow.yml new file mode 100644 index 0000000..0afd5fd --- /dev/null +++ b/q3-cicd/workflow.yml @@ -0,0 +1,44 @@ +name: Ghaymah CI/CD Pipeline + +on: + push: + branches: + - main + +env: + REGISTRY: registry.ghaymah.systems + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout Source Code + uses: actions/checkout@v4 + + - name: Log in to Ghaymah Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ secrets.GHAYMAH_USERNAME }} + password: ${{ secrets.GHAYMAH_TOKEN }} + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5 + with: + context: ./q1-deploy-monitor + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + + deploy-to-production: + needs: build-and-push + runs-on: ubuntu-latest + environment: + name: production + url: https://prod.ghaymah.systems + + steps: + - name: Deploy to Ghaymah Production + run: | + echo "Deploying image ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} to production..." + echo "Deployment Successful!" \ No newline at end of file