From 1db0419b19d95c2c4cf38b2af0c0a78dab41f937 Mon Sep 17 00:00:00 2001 From: momenlotfy Date: Tue, 28 Jul 2026 22:12:40 +0300 Subject: [PATCH] Implement CI/CD pipeline for Ghaymah --- .github/workflows/deploy.yml | 139 ++++++++--------------------------- task1-deploy/.ghaymah.json | 2 +- 2 files changed, 31 insertions(+), 110 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9f3189a..dac738f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,188 +8,109 @@ on: workflow_dispatch: - env: APP_DIR: ./task1-deploy - jobs: - # ================================== - # Build & Validate - # ================================== - build: - - name: Build Docker Image - + name: Build & Validate Docker Image runs-on: ubuntu-latest steps: - - name: Checkout repository uses: actions/checkout@v4 - - - name: Build Docker Image + - name: Build Docker image run: | docker build \ - -t training-api:${{ github.sha }} \ - ${{ env.APP_DIR }} + -t training-api:${{ github.sha }} \ + ${{ env.APP_DIR }} - - - name: Test Docker Image + - name: Run container run: | docker run -d \ - --name test-container \ - -p 8080:8080 \ - training-api:${{ github.sha }} + --name test-container \ + -p 8080:8080 \ + training-api:${{ github.sha }} + - name: Health Check + run: | sleep 5 - curl -f http://localhost:8080/health - docker stop test-container - - - - # ================================== - # Deploy Staging - # ================================== + - name: Cleanup + if: always() + run: | + docker stop test-container || true + docker rm test-container || true deploy-staging: - name: Deploy to Staging - needs: build - runs-on: ubuntu-latest environment: name: staging - steps: - - - name: Checkout repository - uses: actions/checkout@v4 - + - uses: actions/checkout@v4 - name: Install Ghaymah CLI - run: | curl -sSl https://cli.ghaymah.systems/install.sh | bash - echo "$HOME/ghaymah/bin" >> $GITHUB_PATH - - - - name: Authenticate with Ghaymah + # حسب الوثائق الرسمية + - name: Authenticate run: | - gy auth login \ - --token "${{ secrets.GHAYMAH_API_TOKEN }}" - - - - name: Deploy Staging Application + echo "Login using: gy auth login" + - name: Launch Application working-directory: task1-deploy - run: | gy resource app launch - - - name: Smoke Test Staging - + - name: Smoke Test run: | sleep 20 - - curl -f \ - https://task1-deploy-b18316770d08.hosted.ghaymah.systems/health - - - - # ================================== - # Manual Approval - # ================================== + curl -f https://task1-deploy-aee3d4210e10.hosted.ghaymah.systems/health approve-production: - - name: Production Approval - + name: Manual Approval needs: deploy-staging - runs-on: ubuntu-latest environment: name: production-approval - steps: - - - name: Waiting for approval - - run: | - echo "Production deployment approved" - - - - # ================================== - # Production Deployment - # ================================== + - run: echo "Waiting for manual approval" deploy-production: - name: Deploy Production - - needs: - - approve-production - - + needs: approve-production runs-on: ubuntu-latest - environment: name: production - steps: - - - name: Checkout repository - - uses: actions/checkout@v4 - - + - uses: actions/checkout@v4 - name: Install Ghaymah CLI - run: | curl -sSl https://cli.ghaymah.systems/install.sh | bash - echo "$HOME/ghaymah/bin" >> $GITHUB_PATH - - - - - name: Authenticate with Ghaymah + - name: Authenticate run: | - gy auth login \ - --token "${{ secrets.GHAYMAH_API_TOKEN }}" - - - - - name: Deploy Production Application + echo "Login using: gy auth login" + - name: Launch Application working-directory: task1-deploy - run: | - gy resource app launch - - - name: Production Health Check - run: | - sleep 20 - - curl -f \ - https://task1-deploy-b18316770d08.hosted.ghaymah.systems/health + curl -f https://task1-deploy-aee3d4210e10.hosted.ghaymah.systems/health diff --git a/task1-deploy/.ghaymah.json b/task1-deploy/.ghaymah.json index 449219f..190f5fe 100644 --- a/task1-deploy/.ghaymah.json +++ b/task1-deploy/.ghaymah.json @@ -1,5 +1,5 @@ { - "id": "5ba192b0-d1f0-43a6-963d-be133af424b1", + "id": "9d8715ca-42b4-41f1-9852-767c3ffba36f", "name": "task1-deploy", "projectId": "34340b16-24f2-4db9-89e4-bf94bb372e68", "ports": [