Skip to content

Merge pull request #37 from Helaman99/November-2023-Update #36

Merge pull request #37 from Helaman99/November-2023-Update

Merge pull request #37 from Helaman99/November-2023-Update #36

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Politick 2023 API CI/CD
on:
push:
paths:
- Politick.Api/**
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
if: ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' )
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Set up .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: '7.x'
include-prerelease: true
- name: Build with dotnet
working-directory: ./Politick.Api
run: dotnet build --configuration Release
- name: Test with dotnet
working-directory: ./Politick.Api
run: dotnet test
- name: dotnet publish
working-directory: ./Politick.Api
run: dotnet publish Politick.Api -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
deploy:
runs-on: ubuntu-latest
needs: build
if: ((github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'workflow_dispatch' )
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: .net-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{secrets.API_APP_NAME}}
slot-name: 'Production'
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
package: .