Initial Ghaymah tasks setup
هذا الالتزام موجود في:
195
.github/workflows/deploy.yml
مباع
Normal file
195
.github/workflows/deploy.yml
مباع
Normal file
@@ -0,0 +1,195 @@
|
||||
name: Build, Deploy & Monitor Ghaymah Application
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- develop
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
env:
|
||||
APP_DIR: ./task1-deploy
|
||||
|
||||
|
||||
jobs:
|
||||
|
||||
# ==================================
|
||||
# Build & Validate
|
||||
# ==================================
|
||||
|
||||
build:
|
||||
|
||||
name: Build Docker Image
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
|
||||
- name: Build Docker Image
|
||||
run: |
|
||||
docker build \
|
||||
-t training-api:${{ github.sha }} \
|
||||
${{ env.APP_DIR }}
|
||||
|
||||
|
||||
- name: Test Docker Image
|
||||
run: |
|
||||
docker run -d \
|
||||
--name test-container \
|
||||
-p 8080:8080 \
|
||||
training-api:${{ github.sha }}
|
||||
|
||||
sleep 5
|
||||
|
||||
curl -f http://localhost:8080/health
|
||||
|
||||
docker stop test-container
|
||||
|
||||
|
||||
|
||||
# ==================================
|
||||
# Deploy Staging
|
||||
# ==================================
|
||||
|
||||
deploy-staging:
|
||||
|
||||
name: Deploy to Staging
|
||||
|
||||
needs: build
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
environment:
|
||||
name: staging
|
||||
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
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
|
||||
|
||||
run: |
|
||||
gy auth login \
|
||||
--token "${{ secrets.GHAYMAH_API_TOKEN }}"
|
||||
|
||||
|
||||
- name: Deploy Staging Application
|
||||
|
||||
working-directory: task1-deploy
|
||||
|
||||
run: |
|
||||
gy resource app launch
|
||||
|
||||
|
||||
- name: Smoke Test Staging
|
||||
|
||||
run: |
|
||||
sleep 20
|
||||
|
||||
curl -f \
|
||||
https://task1-deploy-b18316770d08.hosted.ghaymah.systems/health
|
||||
|
||||
|
||||
|
||||
# ==================================
|
||||
# Manual Approval
|
||||
# ==================================
|
||||
|
||||
approve-production:
|
||||
|
||||
name: Production Approval
|
||||
|
||||
needs: deploy-staging
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
environment:
|
||||
name: production-approval
|
||||
|
||||
|
||||
steps:
|
||||
|
||||
- name: Waiting for approval
|
||||
|
||||
run: |
|
||||
echo "Production deployment approved"
|
||||
|
||||
|
||||
|
||||
# ==================================
|
||||
# Production Deployment
|
||||
# ==================================
|
||||
|
||||
deploy-production:
|
||||
|
||||
name: Deploy Production
|
||||
|
||||
needs:
|
||||
- approve-production
|
||||
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
||||
environment:
|
||||
name: production
|
||||
|
||||
|
||||
steps:
|
||||
|
||||
- name: Checkout repository
|
||||
|
||||
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
|
||||
|
||||
run: |
|
||||
gy auth login \
|
||||
--token "${{ secrets.GHAYMAH_API_TOKEN }}"
|
||||
|
||||
|
||||
|
||||
- name: Deploy Production 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
|
||||
المرجع في مشكلة جديدة
حظر مستخدم