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