Skip to content

added backend CORS origin address #23

added backend CORS origin address

added backend CORS origin address #23

name: CI/CD
on:
push:
branches: [ "develop" ]
workflow_dispatch:
inputs:
deploy_target:
description: 'Specify which part to deploy: frontend, backend, or both'
required: true
default: 'both'
type: string
env:
AZURE_WEBAPP_NAME_BACKEND: talosave-backend # set this to your backend application's name
AZURE_WEBAPP_PACKAGE_PATH_BACKEND: './ts-backend' # set this to the path to your backend project
AZURE_WEBAPP_NAME_FRONTEND: talosave-frontend # set this to your frontend application's name
AZURE_WEBAPP_PACKAGE_PATH_FRONTEND: './ts-frontend' # set this to the path to your frontend project
NODE_VERSION: '20.x' # set this to the node version to use
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install, build, and test backend
if: ${{ github.event.inputs.deploy_target == 'backend' || github.event.inputs.deploy_target == 'both' }}
run: |
cd ${{ env.AZURE_WEBAPP_PACKAGE_PATH_BACKEND }}
npm install --legacy-peer-deps
npm run build --if-present
npm run test --if-present
- name: Install, build, and test frontend
if: ${{ github.event.inputs.deploy_target == 'frontend' || github.event.inputs.deploy_target == 'both' }}
run: |
cd ${{ env.AZURE_WEBAPP_PACKAGE_PATH_FRONTEND }}
npm install --legacy-peer-deps
npm run build --if-present
npm run test --if-present
- name: Upload backend artifact for deployment job
if: ${{ github.event.inputs.deploy_target == 'backend' || github.event.inputs.deploy_target == 'both' }}
uses: actions/upload-artifact@v3
with:
name: backend-app
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH_BACKEND }}
- name: Upload frontend artifact for deployment job
if: ${{ github.event.inputs.deploy_target == 'frontend' || github.event.inputs.deploy_target == 'both' }}
uses: actions/upload-artifact@v3
with:
name: frontend-app
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH_FRONTEND }}/dist
deploy-backend:
if: ${{ github.event.inputs.deploy_target == 'backend' || github.event.inputs.deploy_target == 'both' }}
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp-backend.outputs.webapp-url }}
steps:
- name: Download backend artifact from build job
uses: actions/download-artifact@v3
with:
name: backend-app
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH_BACKEND }}
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy backend to Azure WebApp'
id: deploy-to-webapp-backend
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME_BACKEND }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH_BACKEND }}
deploy-frontend:
if: ${{ github.event.inputs.deploy_target == 'frontend' || github.event.inputs.deploy_target == 'both' }}
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp-frontend.outputs.webapp-url }}
steps:
- name: Download frontend artifact from build job
uses: actions/download-artifact@v3
with:
name: frontend-app
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH_FRONTEND }}/dist
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: 'Deploy frontend to Azure WebApp'
id: deploy-to-webapp-frontend
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME_FRONTEND }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH_FRONTEND }}/dist