Implement CI/CD pipeline for Ghaymah
هذا الالتزام موجود في:
139
.github/workflows/deploy.yml
مباع
139
.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
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم