name: CI/CD Pipeline - Weather App ๐ŸŒค๏ธ on: push: branches: [ main ] pull_request: jobs: # ----------------------------- # ๐Ÿงช 1. Test job # ----------------------------- test: steps: - name: ๐Ÿงพ Checkout Code uses: actions/checkout@v5.0.0 - name: ๐Ÿ Set up Python uses: actions/setup-python@v5 with: python-version: "3.10" - name: ๐Ÿ“ฆ Install Dependencies run: | python -m venv venv source venv/bin/activate pip install -r requirements.txt pip install pytest pytest-cov flake8 - name: ๐Ÿงช Run Unit Tests run: | source venv/bin/activate pytest --maxfail=1 --disable-warnings -q - name: ๐Ÿ“Š Generate Test Coverage Report run: | source venv/bin/activate pytest --cov=app --cov-report=term-missing # ----------------------------- # ๐Ÿณ 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