Skip to content

Merge pull request #145 from kubapoke/development #75

Merge pull request #145 from kubapoke/development

Merge pull request #145 from kubapoke/development #75

name: Build and deploy Car Search user application
on:
push:
branches:
- development
- main
paths:
- 'car-search/frontend/**'
workflow_dispatch:
jobs:
build:
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: Create .env file for the Car Search Frontend
working-directory: car-search/frontend/car-search
run: |
echo "VITE_CLIENT_ID_FOR_OATH=${{ secrets.SEARCHFRONT_VITE_CLIENT_ID_FOR_OATH }}" > .env
echo "VITE_SERVER_URL=${{ secrets.SEARCHFRONT_VITE_SERVER_URL }}" >> .env
- name: npm install, build, and test
working-directory: car-search/frontend/car-search
run: |
npm install
npm run build --if-present
npm run test --if-present
- name: Create a zip file of the dist directory
working-directory: car-search/frontend/car-search
run: |
echo "Creating a zip file of the dist directory..."
powershell -Command "Compress-Archive -Path dist/* -DestinationPath dist.zip"
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: node-app
path: car-search/frontend/car-search/dist.zip
deploy:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-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@v3
with:
name: node-app
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'carsearch'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_2E07AAC139EF446DA244AC632C954B41 }}
package: dist.zip # Point to the zipped package