Update deploy-to-dev.yml #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and deploy ASP.Net Core app to Dev | |
env: | |
AZURE_WEBAPP_NAME: service-assessment-service | |
AZURE_WEBAPP_PACKAGE_PATH: '.' | |
DOTNET_VERSION: '7.x' | |
APP_NAME: SAS-App | |
on: | |
push: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
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@v4 | |
with: | |
name: ${{ env.APP_NAME }} | |
path: ${{ env.DOTNET_ROOT }}/myapp | |
deploy: | |
permissions: | |
contents: none | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'Dev' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.APP_NAME }} | |
- name: Deploy to Azure Web App | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: ${{ env.AZURE_WEBAPP_NAME }} | |
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }} |