Skip to content

Commit b66a12f

Browse files
authored
Fix Azure Web App deployment workflow
Updated Azure deployment workflow to fix branch specification and improve artifact handling.
1 parent e19ab7b commit b66a12f

1 file changed

Lines changed: 14 additions & 31 deletions

File tree

.github/workflows/031-build-deploy-webapp-to-azure.yml

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,19 @@
1-
# This workflow will build and push a .NET Core app to an Azure Web App when a commit is pushed to your default branch.
2-
#
3-
# This workflow assumes you have already created the target Azure App Service web app.
4-
# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-dotnetcore?tabs=net60&pivots=development-environment-vscode
5-
#
6-
# To configure this workflow:
7-
#
8-
# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal.
9-
# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials
10-
#
11-
# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret.
12-
# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
13-
#
14-
# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the AZURE_WEBAPP_PACKAGE_PATH and DOTNET_VERSION environment variables below.
15-
#
16-
# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions
17-
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
18-
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
19-
201
name: 031-build-deploy-webapp-to-azure
212

223
env:
23-
AZURE_WEBAPP_NAME: appservice-enis # set this to the name of your Azure Web App
24-
DOTNET_VERSION: '6.0.x' # set this to the .NET Core version to use
4+
AZURE_WEBAPP_NAME: appservice-enis
5+
DOTNET_VERSION: '6.0.x'
256

267
on:
278
push:
28-
branches: none
29-
# - main
9+
branches:
10+
- main # fixed (was invalid: branches: none)
3011
workflow_dispatch:
3112

3213
jobs:
3314
build:
3415
runs-on: ubuntu-latest
35-
16+
3617
defaults:
3718
run:
3819
working-directory: 03-app-dotnet
@@ -41,9 +22,10 @@ jobs:
4122
- uses: actions/checkout@v4
4223

4324
- name: Set up .NET Core
44-
uses: actions/setup-dotnet@v3
25+
uses: actions/setup-dotnet@v3
26+
with: # ✅ FIX: missing "with"
4527
dotnet-version: ${{ env.DOTNET_VERSION }}
46-
28+
4729
- name: Set up dependency caching for faster builds
4830
uses: actions/cache@v4
4931
with:
@@ -56,26 +38,27 @@ jobs:
5638
run: dotnet build --configuration Release
5739

5840
- name: dotnet publish
59-
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
41+
run: dotnet publish -c Release -o ./publish # ✅ safer path
6042

6143
- name: Upload artifact for deployment job
6244
uses: actions/upload-artifact@v4
6345
with:
64-
name: .net-app
65-
path: ${{env.DOTNET_ROOT}}/myapp
46+
name: dotnet-app # ✅ avoid dot in name
47+
path: ./publish
6648

6749
deploy:
6850
runs-on: ubuntu-latest
6951
needs: build
52+
7053
environment:
71-
name: 'Development'
54+
name: Development
7255
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
7356

7457
steps:
7558
- name: Download artifact from build job
7659
uses: actions/download-artifact@v4
7760
with:
78-
name: .net-app
61+
name: dotnet-app
7962

8063
- name: Deploy to Azure Web App
8164
id: deploy-to-webapp

0 commit comments

Comments
 (0)