Skip to content

Remove Policy

Remove Policy #45

name: Backend - Build and Deploy
on:
push:
paths:
- src/BackEnd/**
- src/Directory.Build.props
- .github/workflows/build-and-deploy-backend.yml
env:
DOTNET_VERSION: '8.0.x'
DOTNET_APP_SOURCE_PATH: './src/'
DOTNET_APP_BACKEND_SOLUTION: 'Wsa.Gaas.Werewolf.BackEnd.sln'
DOTNET_APP_BACKEND_PROJECT_PATH: './src/BackEnd/src/Presentation/WebApi'
jobs:
build:
name: Build, Test and Publish Artifact
runs-on: ubuntu-latest
steps:
# Checkout the repo
- name: git checkout
uses: actions/checkout@v3
# Setup .NET SDK
- name: Setup .NET SDK ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# Run dotnet build and test
- name: Backend - dotnet restore, build and test
working-directory: ${{ env.DOTNET_APP_SOURCE_PATH }}
run: |
dotnet restore ${{ env.DOTNET_APP_BACKEND_SOLUTION }}
dotnet build ${{ env.DOTNET_APP_BACKEND_SOLUTION }} -c Release --no-restore
dotnet test ${{ env.DOTNET_APP_BACKEND_SOLUTION }} -c Release --no-build --verbosity normal
# Run dotnet publish
- name: Backend - dotnet publish
if: github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'master')
run: |
dotnet publish ${{ env.DOTNET_APP_BACKEND_PROJECT_PATH }} -c Release -r linux-x64 --no-self-contained -o publish/backend /p:DebugType=None /p:DebugSymbols=false
# Upload Artifact
- name: Backend - Upload Artifact
if: github.event_name == 'push' && (github.ref_name == 'develop' || github.ref_name == 'master')
uses: actions/upload-artifact@v3
with:
name: backend-app
path: publish/backend
# Dump GitHub Context
- name: Dump GitHub Context
run: |
echo '```' >> $GITHUB_STEP_SUMMARY
echo '${{ toJSON(env) }}' >> $GITHUB_STEP_SUMMARY
echo '${{ toJSON(github) }}' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
deploy-backend-dev:
name: Deploy Backend Dev
if: github.ref_name == 'develop' && github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
environment: dev
env:
AZURE_BACKEND_WEBAPP_NAME: 'werewolf-api-dev'
steps:
# Download All Artifacts
- name: Download All Artifacts
uses: actions/download-artifact@v3
# Display file structures
- name: Display structure of downloaded files
run: ls -R
# Deploy to Azure App Service
- name: Deploy to Backend Azure App Service
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_BACKEND_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_BACKEND_WEBAPP_PUBLISH_PROFILE }}
package: './backend-app'
deploy-production:
name: Deploy Production
if: github.ref_name == 'main' && github.event_name == 'push'
needs: build
runs-on: ubuntu-latest
environment: production
env:
AZURE_WEBAPP_NAME: 'werewolf-api-dev'
steps:
# Download Artifact
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: backend-app
path: ./backend-app
# Display file structures
- name: Display structure of downloaded files
run: ls -R
# Deploy to Azure App Service
- name: Deploy to Azure App Service
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: './backend-app'