Skip to content

feat: streamline database migration process in build workflow #8

feat: streamline database migration process in build workflow

feat: streamline database migration process in build workflow #8

name: API CI
on:
workflow_dispatch:
push:
branches:
- main
env:
AZURE_WEBAPP_NAME: frontierfinds
AZURE_WEBAPP_PACKAGE_PATH: "./Source/Ecommerce.Api/publish"
DOTNET_VERSION: "9.0.100"
SOLUTION_PATH: "FrontierFinds.sln"
API_PROJECT_PATH: "./Source/Ecommerce.Api"
PUBLISH_DIR: "./publish"
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore
run: dotnet restore ${{ env.SOLUTION_PATH }}
- name: Build
run: dotnet build ${{ env.SOLUTION_PATH }} --configuration Release --no-restore
- name: Install Tools
run: dotnet tool install --tool-path .tools dotnet-ef --version 9.0.0
- name: Run Database Migrations
run: dotnet tool run dotnet-ef database update --project ./Source/Ecommerce.Infrastructure --configuration Release --no-build
# - name: Test
# run: dotnet test ${{ env.SOLUTION_PATH }} --configuration Release --no-restore --no-build --verbosity normal
- name: Publish
run: dotnet publish ${{ env.API_PROJECT_PATH }} --configuration Release --no-restore --no-build --property:PublishDir=${{ env.PUBLISH_DIR }}
- name: Publish Artifacts
uses: actions/upload-artifact@v4
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
deploy:
name: Deploy to Azure
runs-on: ubuntu-latest
needs: [build-and-test]
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: webapp
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Deploy
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"