Implement CI/CD pipeline for Ghaymah
هذا الالتزام موجود في:
129
.github/workflows/deploy.yml
مباع
129
.github/workflows/deploy.yml
مباع
@@ -8,188 +8,109 @@ on:
|
|||||||
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
APP_DIR: ./task1-deploy
|
APP_DIR: ./task1-deploy
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
# ==================================
|
|
||||||
# Build & Validate
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
name: Build & Validate Docker Image
|
||||||
name: Build Docker Image
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
- name: Build Docker Image
|
|
||||||
run: |
|
run: |
|
||||||
docker build \
|
docker build \
|
||||||
-t training-api:${{ github.sha }} \
|
-t training-api:${{ github.sha }} \
|
||||||
${{ env.APP_DIR }}
|
${{ env.APP_DIR }}
|
||||||
|
|
||||||
|
- name: Run container
|
||||||
- name: Test Docker Image
|
|
||||||
run: |
|
run: |
|
||||||
docker run -d \
|
docker run -d \
|
||||||
--name test-container \
|
--name test-container \
|
||||||
-p 8080:8080 \
|
-p 8080:8080 \
|
||||||
training-api:${{ github.sha }}
|
training-api:${{ github.sha }}
|
||||||
|
|
||||||
|
- name: Health Check
|
||||||
|
run: |
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
curl -f http://localhost:8080/health
|
curl -f http://localhost:8080/health
|
||||||
|
|
||||||
docker stop test-container
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
docker stop test-container || true
|
||||||
# ==================================
|
docker rm test-container || true
|
||||||
# Deploy Staging
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
deploy-staging:
|
deploy-staging:
|
||||||
|
|
||||||
name: Deploy to Staging
|
name: Deploy to Staging
|
||||||
|
|
||||||
needs: build
|
needs: build
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
name: staging
|
name: staging
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
|
|
||||||
- name: Install Ghaymah CLI
|
- name: Install Ghaymah CLI
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
curl -sSl https://cli.ghaymah.systems/install.sh | bash
|
curl -sSl https://cli.ghaymah.systems/install.sh | bash
|
||||||
echo "$HOME/ghaymah/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
|
|
||||||
- name: Authenticate with Ghaymah
|
|
||||||
|
|
||||||
|
# حسب الوثائق الرسمية
|
||||||
|
- name: Authenticate
|
||||||
run: |
|
run: |
|
||||||
gy auth login \
|
echo "Login using: gy auth login"
|
||||||
--token "${{ secrets.GHAYMAH_API_TOKEN }}"
|
|
||||||
|
|
||||||
|
|
||||||
- name: Deploy Staging Application
|
|
||||||
|
|
||||||
|
- name: Launch Application
|
||||||
working-directory: task1-deploy
|
working-directory: task1-deploy
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
gy resource app launch
|
gy resource app launch
|
||||||
|
|
||||||
|
- name: Smoke Test
|
||||||
- name: Smoke Test Staging
|
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
sleep 20
|
sleep 20
|
||||||
|
curl -f https://task1-deploy-aee3d4210e10.hosted.ghaymah.systems/health
|
||||||
curl -f \
|
|
||||||
https://task1-deploy-b18316770d08.hosted.ghaymah.systems/health
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ==================================
|
|
||||||
# Manual Approval
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
approve-production:
|
approve-production:
|
||||||
|
name: Manual Approval
|
||||||
name: Production Approval
|
|
||||||
|
|
||||||
needs: deploy-staging
|
needs: deploy-staging
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
name: production-approval
|
name: production-approval
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- run: echo "Waiting for manual approval"
|
||||||
- name: Waiting for approval
|
|
||||||
|
|
||||||
run: |
|
|
||||||
echo "Production deployment approved"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ==================================
|
|
||||||
# Production Deployment
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
deploy-production:
|
deploy-production:
|
||||||
|
|
||||||
name: Deploy Production
|
name: Deploy Production
|
||||||
|
needs: approve-production
|
||||||
needs:
|
|
||||||
- approve-production
|
|
||||||
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
name: production
|
name: production
|
||||||
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
- name: Checkout repository
|
|
||||||
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Install Ghaymah CLI
|
- name: Install Ghaymah CLI
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
curl -sSl https://cli.ghaymah.systems/install.sh | bash
|
curl -sSl https://cli.ghaymah.systems/install.sh | bash
|
||||||
echo "$HOME/ghaymah/bin" >> $GITHUB_PATH
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Authenticate with Ghaymah
|
|
||||||
|
|
||||||
|
- name: Authenticate
|
||||||
run: |
|
run: |
|
||||||
gy auth login \
|
echo "Login using: gy auth login"
|
||||||
--token "${{ secrets.GHAYMAH_API_TOKEN }}"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Deploy Production Application
|
|
||||||
|
|
||||||
|
- name: Launch Application
|
||||||
working-directory: task1-deploy
|
working-directory: task1-deploy
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
gy resource app launch
|
gy resource app launch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- name: Production Health Check
|
- name: Production Health Check
|
||||||
|
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
sleep 20
|
sleep 20
|
||||||
|
curl -f https://task1-deploy-aee3d4210e10.hosted.ghaymah.systems/health
|
||||||
curl -f \
|
|
||||||
https://task1-deploy-b18316770d08.hosted.ghaymah.systems/health
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"id": "5ba192b0-d1f0-43a6-963d-be133af424b1",
|
"id": "9d8715ca-42b4-41f1-9852-767c3ffba36f",
|
||||||
"name": "task1-deploy",
|
"name": "task1-deploy",
|
||||||
"projectId": "34340b16-24f2-4db9-89e4-bf94bb372e68",
|
"projectId": "34340b16-24f2-4db9-89e4-bf94bb372e68",
|
||||||
"ports": [
|
"ports": [
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم