diff --git a/.github/workflows/deploy_we-chat.yml b/.github/workflows/deploy_we-chat.yml new file mode 100644 index 0000000..7179700 --- /dev/null +++ b/.github/workflows/deploy_we-chat.yml @@ -0,0 +1,63 @@ +# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy +# More GitHub Actions for Azure: https://github.com/Azure/actions +# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions + +name: Build and deploy Python app to Azure Web App - we-chat + +on: + push: + branches: + - deploy + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python version + uses: actions/setup-python@v1 + with: + python-version: '3.10' + + - name: Create and start virtual environment + run: | + python -m venv venv + source venv/bin/activate + + - name: Install dependencies + run: pip install -r requirements.txt + + # Optional: Add step to run tests here (PyTest, Django test suites, etc.) + + - name: Upload artifact for deployment jobs + uses: actions/upload-artifact@v2 + with: + name: python-app + path: | + . + !venv/ + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: 'Production' + url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} + + steps: + - name: Download artifact from build job + uses: actions/download-artifact@v2 + with: + name: python-app + path: . + + - name: 'Deploy to Azure Web App' + uses: azure/webapps-deploy@v2 + id: deploy-to-webapp + with: + app-name: 'we-chat' + slot-name: 'Production' + publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_CDF3B4DE7D12465F85761BD9A67FA7E3 }} diff --git a/application.py b/application.py index d440be3..1383893 100644 --- a/application.py +++ b/application.py @@ -10,7 +10,7 @@ # Configure App app = Flask(__name__) -app.secret_key = os.environ.get('SECRET') +app.secret_key = os.environ.get('SECRET_KEY') #Configure database app.config['SQLALCHEMY_DATABASE_URI']= os.environ.get('DATABASE_URL') @@ -115,4 +115,4 @@ def leave(data): if __name__ =="__main__": - app.run() \ No newline at end of file + app.run() diff --git a/models.py b/models.py index 8967eac..1c63270 100644 --- a/models.py +++ b/models.py @@ -1,8 +1,11 @@ from enum import unique from flask_sqlalchemy import SQLAlchemy from flask_login import UserMixin +from flask import Flask -db = SQLAlchemy() +app = Flask(__name__) + +db = SQLAlchemy(app) class User(UserMixin, db.Model): """User Model""" @@ -11,4 +14,4 @@ class User(UserMixin, db.Model): username = db.Column(db.String(25), unique=True, nullable=False) password=db.Column(db.String(), nullable=False) - +# db.create_all()