Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
10,093 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I AM USING AZURE WEB APP SERVICE TO DEPLOY MY REACT APPLICATION BUILD THROUGH VITE . I AM USING GITHUB ACTIONS FOR CI/CD DEPLOYMENT . I WANTED TO USE ENVIRONMENT VARIABELS IN MY REACT APP WHICH I USED AS :
<div>Todo
{import.meta.env.VITE_SOME_KEY}
</div>
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig({
plugins: [react()],
build: {
rollupOptions: {
output: {
inlineDynamicImports: true,
globals: {
'import.meta.env.VITE_SOME_KEY': JSON.stringify(process.env.VITE_SOME_KEY||'ABC'),
},
},
},
},
});
name: Build and deploy Node.js app to Azure Web App - my-notes
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '20.x'
- name: npm install, build, and test
run: |
npm install
npm run build --if-present
npm run test --if-present
# zip the build directory
- name: Zip Release
uses: TheDoctor0/zip-release@0.7.1
with:
filename: release.zip
# Base path for archive files
path: ./dist/*
# Working directory before zipping
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: node-app
path: release.zip
deploy:
runs-on: windows-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: node-app
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'my-notes'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_D81356694B8E443E8730CBE89FE4B78A }}
package: release.zip