Update App.js #7
This file contains hidden or 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: Backend Deployment | |
on: | |
push: | |
branches: | |
- master | |
env: | |
WEBAPP_NAME: xcan-server | |
PUBLISHED_PACKAGE_PATH: XCan.Api/publish | |
CONFIGURATION: Release | |
DOTNET_VERSION: 8.0.x | |
WORKING_DIRECTORY: XCan.Api | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: ${{ env.DOTNET_VERSION }} | |
- name: Cache NuGet packages | |
uses: actions/cache@v3 | |
with: | |
path: ~/.nuget/packages | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} | |
restore-keys: | | |
${{ runner.os }}-nuget- | |
- name: Restore dependencies | |
run: dotnet restore ${{ env.WORKING_DIRECTORY }} | |
- name: Build | |
run: dotnet build ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-restore | |
- name: Test | |
run: dotnet test ${{ env.WORKING_DIRECTORY }} --no-build | |
- name: Publish | |
run: dotnet publish ${{ env.WORKING_DIRECTORY }} --configuration ${{ env.CONFIGURATION }} --no-build --output ${{ env.PUBLISHED_PACKAGE_PATH }} | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: webapp | |
path: ${{ env.PUBLISHED_PACKAGE_PATH }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: 'Production' | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
permissions: | |
id-token: write #This is required for requesting the JWT | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v3 | |
with: | |
name: webapp | |
path: ${{ env.PUBLISHED_PACKAGE_PATH }} | |
- name: Login to Azure | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_A37EF58390764636951333F2DE8B472A }} | |
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_E4FFC022D1894E5E84E13D203070EAC7 }} | |
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_69FFD809484445A8B2F067F8E28286ED }} | |
- name: Deploy to Azure | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v3 | |
with: | |
app-name: ${{ env.WEBAPP_NAME }} | |
slot-name: 'Production' | |
package: ${{ env.PUBLISHED_PACKAGE_PATH }} | |