Skip to content

Commit

Permalink
update deploy_to_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dfeetenby authored and dfeetenby committed Jan 17, 2024
1 parent 12543cf commit 2d1f1c0
Showing 1 changed file with 55 additions and 21 deletions.
76 changes: 55 additions & 21 deletions .github/workflows/deploy-to-dev.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,97 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy to dev

env:
AZURE_WEBAPP_NAME: service-assessment-service-dev
AZURE_WEBAPP_PACKAGE_PATH: "./src"
DOTNET_VERSION: "7.x"
AZURE_WEBAPP_NAME: service-assessment-service # set this to the name of your Azure Web App
AZURE_WEBAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: "7.x" # set this to the .NET Core version to use
APP_NAME: SAS-App

on:
push:
branches:
- main
branches: ["main"]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: windows-latest
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
include-prerelease: true
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Setup Node.js environment
uses: actions/[email protected]
with:
## NOTE: dfe-frontend-alpha advertises requirement of node 16, with console warnings/errors if using more recent version
node-version: 16

- name: Cache node_modules
id: node_modules-cache-webapp
uses: actions/cache@v3
with:
path: ./src/ServiceAssessmentService/ServiceAssessmentService.WebApp/node_modules
key: ${{ runner.os }}-node_modules-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Install NPM dependencies (Web UI)
working-directory: ./src/ServiceAssessmentService/ServiceAssessmentService.WebApp
run: npm install

- name: Set up dependency caching for faster builds
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Build Web UI (webpack)
working-directory: ./src/ServiceAssessmentService/ServiceAssessmentService.WebApp
run: npm run buildCi

- name: Verify formatting
working-directory: ./src/ServiceAssessmentService
run: dotnet format --no-restore --verify-no-changes

- name: Build with dotnet
working-directory: ./src/ServiceAssessmentService
run: dotnet build --configuration Release

- name: dotnet publish
working-directory: ./src/ServiceAssessmentService
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: .net-app
name: ${{ env.APP_NAME }}
path: ${{env.DOTNET_ROOT}}/myapp

deploy:
runs-on: windows-latest
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: "Production"
name: "Dev"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: .net-app
name: ${{ env.APP_NAME }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
uses: azure/webapps-deploy@v3
with:
app-name: "service-assessment-service"
slot-name: "Production"
package: .
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

0 comments on commit 2d1f1c0

Please sign in to comment.