From 36b8db7cb7c9a3ba5bf7a2a78dfd4515d8019ca8 Mon Sep 17 00:00:00 2001 From: Likhon Sheikh Date: Thu, 27 Jun 2024 06:54:57 +0600 Subject: [PATCH] Update deploy.yml --- .github/workflows/deploy.yml | 69 +++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 50b776b..5595e96 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,32 +1,51 @@ -name: Deploy +name: Python application on: push: - branches: - - main # or any other branch you use for deployment + branches: [ $default-branch ] + pull_request: + branches: [ $default-branch ] + +permissions: + contents: read jobs: - deploy: + build: + runs-on: ubuntu-latest - environment: - name: production # The name of the environment where you've configured your secrets + steps: - - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' # Ensure this matches your project's requirements - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Deploy - env: - MONGODB_URI: ${{ secrets.MONGODB_URI }} - TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} - run: | - # Run your application or deployment script here - python3 app.py + - uses: actions/checkout@v4 + + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python3 -m venv venv + source venv/bin/activate + python3 -m pip install -r requirements.txt + + - name: Lint with flake8 + run: | + source venv/bin/activate + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Test with pytest + run: | + source venv/bin/activate + pytest + + - name: Deploy Python App + env: + MONGODB_URI: ${{ secrets.MONGODB_URI }} + TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} + run: | + source venv/bin/activate + python3 app.py