Skip to content

Commit

Permalink
Merge pull request #47 from dantelmomsft/github-actions-apps
Browse files Browse the repository at this point in the history
GitHub actions for backend and frontend apps
  • Loading branch information
pablomarin authored Jun 22, 2023
2 parents ce4a750 + 364e122 commit da9d1ca
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 64 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-3.10",

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install -r ./common/requirements.txt",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-toolsai.jupyter",
"ms-python.python"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
63 changes: 0 additions & 63 deletions .github/workflows/main_gptsmartsearch.yml

This file was deleted.

124 changes: 124 additions & 0 deletions .github/workflows/main_gptsmartsearch_apps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# 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: GPTSmartSearch Apps Deployment
env:
DO_BUILD_DURING_DEPLOYMENT: true

on:
push:
branches:
- github-actions-apps
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
outputs:
env-name: ${{steps.set-deploy-env.outputs.DEPLOY_ENVIRONMENT}}
steps:
- uses: actions/checkout@v2

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.10'

- name: Set environment for branch
id: set-deploy-env
run: |
if [[ $GITHUB_REF_NAME == 'refs/heads/main' ]]; then
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
elif [[ $GITHUB_REF_NAME == 'refs/heads/develop' ]]; then
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
elif [[ $GITHUB_REF_NAME == 'refs/heads/release' ]]; then
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
else
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
fi
- name: merge backend and common folder
run: |
echo "Prepare backend source for enviroment [${{ steps.set-deploy-env.outputs.DEPLOY_ENVIRONMENT }}]"
mkdir -p ./target/backend
cp -r ./apps/backend ./target
cp -r ./common/*.* ./target/backend
- name: Create and start virtual environment in backend folder
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
run: |
python -m venv ./target/backend/venv
source ./target/backend/venv/bin/activate
- name: Install backend dependencies
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
run: pip install -r ./target/backend/requirements.txt

- name: merge frontend and common folder
run: |
echo "Prepare frontend source for enviroment [${{ steps.set-deploy-env.outputs.DEPLOY_ENVIRONMENT }}]"
mkdir -p ./target/frontend
cp -r ./apps/frontend ./target
cp -r ./common/*.* ./target/frontend
- name: Create and start virtual environment in frontend folder
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
run: |
python -m venv ./target/frontend/venv
source ./target/frontend/venv/bin/activate
- name: Install frontend dependencies
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
run: pip install -r ./target/frontend/requirements.txt
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifacts for backend deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-backend-app
path: |
./target/backend
- name: Upload artifacts for frontend deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-frontend-app
path: |
./target/frontend
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: ${{ needs.build.outputs.env-name}}
url: ${{ steps.deploy-frontend-to-webapp.outputs.webapp-url }}

steps:
- name: Download backend artifact from build job
uses: actions/download-artifact@v2
with:
name: python-backend-app
path: ./backend

- name: 'Deploy backend to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-backend-to-webapp
with:
app-name: ${{ vars.AZURE_WEBAPP_BACKEND_NAME }}
package: ./backend
publish-profile: ${{ secrets.AZUREAPPSERVICE_BACKEND_PUBLISHPROFILE}}

- name: Download frontend artifact from build job
uses: actions/download-artifact@v2
with:
name: python-frontend-app
path: ./frontend

- name: 'Deploy frontend to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-frontend-to-webapp
with:
app-name: ${{ vars.AZURE_WEBAPP_FRONTEND_NAME }}
package: ./frontend
publish-profile: ${{ secrets.AZUREAPPSERVICE_FRONTEND_PUBLISHPROFILE}}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.amlignore
.zip
.chroma/
.github/
.ipynb_checkpoints/
.ipynb_aml_checkpoints/
__pycache__/
Expand Down

0 comments on commit da9d1ca

Please sign in to comment.