Skip to content

Commit da9d1ca

Browse files
authored
Merge pull request #47 from dantelmomsft/github-actions-apps
GitHub actions for backend and frontend apps
2 parents ce4a750 + 364e122 commit da9d1ca

File tree

4 files changed

+153
-64
lines changed

4 files changed

+153
-64
lines changed

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
3+
{
4+
"name": "Python 3",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/python:0-3.10",
7+
8+
// Features to add to the dev container. More info: https://containers.dev/features.
9+
// "features": {},
10+
11+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
12+
// "forwardPorts": [],
13+
14+
// Use 'postCreateCommand' to run commands after the container is created.
15+
"postCreateCommand": "pip install -r ./common/requirements.txt",
16+
17+
// Configure tool-specific properties.
18+
"customizations": {
19+
"vscode": {
20+
"extensions": [
21+
"ms-toolsai.jupyter",
22+
"ms-python.python"
23+
]
24+
}
25+
}
26+
27+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28+
// "remoteUser": "root"
29+
}

.github/workflows/main_gptsmartsearch.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-actions
4+
5+
name: GPTSmartSearch Apps Deployment
6+
env:
7+
DO_BUILD_DURING_DEPLOYMENT: true
8+
9+
on:
10+
push:
11+
branches:
12+
- github-actions-apps
13+
- main
14+
workflow_dispatch:
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
env-name: ${{steps.set-deploy-env.outputs.DEPLOY_ENVIRONMENT}}
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up Python version
25+
uses: actions/setup-python@v1
26+
with:
27+
python-version: '3.10'
28+
29+
- name: Set environment for branch
30+
id: set-deploy-env
31+
run: |
32+
if [[ $GITHUB_REF_NAME == 'refs/heads/main' ]]; then
33+
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
34+
elif [[ $GITHUB_REF_NAME == 'refs/heads/develop' ]]; then
35+
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
36+
elif [[ $GITHUB_REF_NAME == 'refs/heads/release' ]]; then
37+
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "DEPLOY_ENVIRONMENT=Development" >> "$GITHUB_OUTPUT"
40+
fi
41+
- name: merge backend and common folder
42+
run: |
43+
echo "Prepare backend source for enviroment [${{ steps.set-deploy-env.outputs.DEPLOY_ENVIRONMENT }}]"
44+
mkdir -p ./target/backend
45+
cp -r ./apps/backend ./target
46+
cp -r ./common/*.* ./target/backend
47+
48+
- name: Create and start virtual environment in backend folder
49+
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
50+
run: |
51+
python -m venv ./target/backend/venv
52+
source ./target/backend/venv/bin/activate
53+
54+
- name: Install backend dependencies
55+
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
56+
run: pip install -r ./target/backend/requirements.txt
57+
58+
- name: merge frontend and common folder
59+
run: |
60+
echo "Prepare frontend source for enviroment [${{ steps.set-deploy-env.outputs.DEPLOY_ENVIRONMENT }}]"
61+
mkdir -p ./target/frontend
62+
cp -r ./apps/frontend ./target
63+
cp -r ./common/*.* ./target/frontend
64+
65+
- name: Create and start virtual environment in frontend folder
66+
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
67+
run: |
68+
python -m venv ./target/frontend/venv
69+
source ./target/frontend/venv/bin/activate
70+
71+
- name: Install frontend dependencies
72+
if: ${{ !env.DO_BUILD_DURING_DEPLOYMENT }}
73+
run: pip install -r ./target/frontend/requirements.txt
74+
# Optional: Add step to run tests here (PyTest, Django test suites, etc.)
75+
76+
- name: Upload artifacts for backend deployment jobs
77+
uses: actions/upload-artifact@v2
78+
with:
79+
name: python-backend-app
80+
path: |
81+
./target/backend
82+
83+
- name: Upload artifacts for frontend deployment jobs
84+
uses: actions/upload-artifact@v2
85+
with:
86+
name: python-frontend-app
87+
path: |
88+
./target/frontend
89+
90+
deploy:
91+
runs-on: ubuntu-latest
92+
needs: build
93+
environment:
94+
name: ${{ needs.build.outputs.env-name}}
95+
url: ${{ steps.deploy-frontend-to-webapp.outputs.webapp-url }}
96+
97+
steps:
98+
- name: Download backend artifact from build job
99+
uses: actions/download-artifact@v2
100+
with:
101+
name: python-backend-app
102+
path: ./backend
103+
104+
- name: 'Deploy backend to Azure Web App'
105+
uses: azure/webapps-deploy@v2
106+
id: deploy-backend-to-webapp
107+
with:
108+
app-name: ${{ vars.AZURE_WEBAPP_BACKEND_NAME }}
109+
package: ./backend
110+
publish-profile: ${{ secrets.AZUREAPPSERVICE_BACKEND_PUBLISHPROFILE}}
111+
112+
- name: Download frontend artifact from build job
113+
uses: actions/download-artifact@v2
114+
with:
115+
name: python-frontend-app
116+
path: ./frontend
117+
118+
- name: 'Deploy frontend to Azure Web App'
119+
uses: azure/webapps-deploy@v2
120+
id: deploy-frontend-to-webapp
121+
with:
122+
app-name: ${{ vars.AZURE_WEBAPP_FRONTEND_NAME }}
123+
package: ./frontend
124+
publish-profile: ${{ secrets.AZUREAPPSERVICE_FRONTEND_PUBLISHPROFILE}}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
.amlignore
22
.zip
33
.chroma/
4-
.github/
54
.ipynb_checkpoints/
65
.ipynb_aml_checkpoints/
76
__pycache__/

0 commit comments

Comments
 (0)