-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/junioranheu/auth-api
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: Build and deploy .NET API app to Azure Web App | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Trigger on commits to the main branch | ||
workflow_dispatch: | ||
|
||
env: | ||
DOTNET_VERSION: '8.x' # .NET SDK version to use | ||
BUILD_CONFIGURATION: 'Release' # Build configuration | ||
AZURE_WEBAPP_NAME: 'AuthAPI22' # Your Azure Web App name | ||
AZURE_WEBAPP_PUBLISH_PROFILE: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Azure publish profile secret | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ env.DOTNET_VERSION }} | ||
|
||
- name: Restore .NET dependencies | ||
run: dotnet restore Auth.API/Auth.API.csproj | ||
|
||
- name: Build .NET project | ||
run: dotnet build Auth.API/Auth.API.csproj --configuration ${{ env.BUILD_CONFIGURATION }} | ||
|
||
- name: Run unit tests | ||
run: dotnet test Auth.API/Auth.API.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity normal | ||
|
||
- name: Publish .NET project | ||
run: dotnet publish Auth.API/Auth.API.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --output ${{ github.workspace }}/publish | ||
|
||
- name: List published files | ||
run: ls -R ${{ github.workspace }}/publish | ||
|
||
- name: Upload artifact for deployment job | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dotnet-api | ||
path: publish/ | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Download artifact from build job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dotnet-api | ||
path: download/ | ||
|
||
- name: List files in artifact | ||
run: ls -R download/ | ||
|
||
- name: Deploy to Azure Web App | ||
uses: azure/webapps-deploy@v2 | ||
with: | ||
app-name: ${{ env.AZURE_WEBAPP_NAME }} | ||
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | ||
package: download/ |