Skip to content

Backend: Update UserBasket to return Products #68

Backend: Update UserBasket to return Products

Backend: Update UserBasket to return Products #68

name: Azure Static Web Apps and Azure App Services CI/CD
on:
push:
branches:
- main
paths:
- 'frontend/**'
- 'backend/**'
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- 'frontend/**'
- 'backend/**'
workflow_dispatch:
jobs:
# Frontend job (build and deploy only if changes are in the frontend directory)
build_and_deploy_frontend:
if: contains(github.event.head_commit.message, 'frontend')
runs-on: ubuntu-latest
name: Build and Deploy Frontend
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Build and Deploy Frontend
id: builddeployfrontend
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_DESERT_0A59D0B03 }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: "upload"
app_location: "./frontend" # App source code path
api_location: "" # API source code path - optional
output_location: "build" # Built app content directory - optional
env:
REACT_APP_AUTH_CLIENT_ID: ${{ secrets.REACT_APP_AUTH_CLIENT_ID }}
REACT_APP_AUTH_DOMAIN: ${{ secrets.REACT_APP_AUTH_DOMAIN }}
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }}
# Backend job (build and deploy only if changes are in the backend directory)
build_and_deploy_backend:
if: contains(github.event.head_commit.message, 'backend')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '20.x'
- name: npm install, build, and test
run: |
npm install
working-directory: ./backend
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: ./backend
# Deployment job
deploy:
runs-on: ubuntu-latest
needs: build_and_deploy_backend # Ensure this points to the correct build job
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: 'Lagunabutchery'
slot-name: 'Production'
package: .
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D138B90A0ED54115975467244D32F7EC }}
env:
SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }}
DB_URI: ${{ secrets.DB_URI }}