Updating CICD Workflow & Creating .ghaymah.json
هذا الالتزام موجود في:
17
.ghaymah.json
Normal file
17
.ghaymah.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"id": "712236a8-9f84-41bf-a8e8-08455a63a53e",
|
||||||
|
"name": "building-api-and-monitoring-logs",
|
||||||
|
"projectId": "9bf7b7b1-dd1d-48e5-bf06-52130c641683",
|
||||||
|
"ports": [
|
||||||
|
{
|
||||||
|
"expose": true,
|
||||||
|
"number": 5000
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"publicAccess": {
|
||||||
|
"enabled": true,
|
||||||
|
"domain": "auto"
|
||||||
|
},
|
||||||
|
"resourceTier": "t1",
|
||||||
|
"dockerFileName": "Dockerfile"
|
||||||
|
}
|
||||||
33
.github/workflows/ci.yml
مباع
33
.github/workflows/ci.yml
مباع
@@ -1,33 +0,0 @@
|
|||||||
name: CI - Fruit API
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "main" ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ "main" ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-test:
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Set up Python
|
|
||||||
uses: actions/setup-python@v4
|
|
||||||
with:
|
|
||||||
python-version: "3.10"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install -r requirements.txt
|
|
||||||
|
|
||||||
- name: Run API in background
|
|
||||||
run: |
|
|
||||||
python fruit_api.py &
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
- name: Run API tests
|
|
||||||
run: |
|
|
||||||
chmod +x test_api.sh
|
|
||||||
./test_api.sh
|
|
||||||
82
.github/workflows/cicd.yml
مباع
Normal file
82
.github/workflows/cicd.yml
مباع
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
name: CI/CD Pipeline of Fruit API
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# 🧪 1. Test job
|
||||||
|
# -----------------------------
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-test:
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Run API in background
|
||||||
|
run: |
|
||||||
|
python fruit_api.py &
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
- name: Run API tests
|
||||||
|
run: |
|
||||||
|
chmod +x test_api.sh
|
||||||
|
./test_api.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# 🐳 2. Build and Push Docker Image
|
||||||
|
# -----------------------------
|
||||||
|
build_and_push_image:
|
||||||
|
needs: test
|
||||||
|
steps:
|
||||||
|
- name: 📦 Checkout Code
|
||||||
|
uses: actions/checkout@v5.0.0
|
||||||
|
|
||||||
|
- name: 🔐 Login to DockerHub
|
||||||
|
uses: docker/login-action@v3.6.0
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: 🐳 Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ahmedgamalyousef/firstcicd:latest
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------
|
||||||
|
# ☁️ 3. Deploy to Ghaymah Cloud
|
||||||
|
# -----------------------------
|
||||||
|
deploy:
|
||||||
|
needs: build_and_push_image
|
||||||
|
steps:
|
||||||
|
- name: 📦 Checkout Code
|
||||||
|
uses: actions/checkout@v5.0.0
|
||||||
|
|
||||||
|
- name: 🌩️ Install Ghaymah CLI
|
||||||
|
run: curl -sSl https://cli.ghaymah.systems/install.sh | bash
|
||||||
|
|
||||||
|
- name: 🔐 Login to Ghaymah Cloud
|
||||||
|
run: $HOME/ghaymah/bin/gy auth login --email "${{ secrets.GHAYMAH_EMAIL }}" --password "${{ secrets.GHAYMAH_PW }}"
|
||||||
|
|
||||||
|
- name: 🚀 Deploy Application
|
||||||
|
run: $HOME/ghaymah/bin/gy resource app launch
|
||||||
|
|
||||||
المرجع في مشكلة جديدة
حظر مستخدم