Updating CICD Workflow & Creating .ghaymah.json
هذا الالتزام موجود في:
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
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم