-
Notifications
You must be signed in to change notification settings - Fork 942
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from dantelmomsft/github-actions-apps
GitHub actions for backend and frontend apps
- Loading branch information
Showing
4 changed files
with
153 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
.amlignore | ||
.zip | ||
.chroma/ | ||
.github/ | ||
.ipynb_checkpoints/ | ||
.ipynb_aml_checkpoints/ | ||
__pycache__/ | ||
|