Skip to content

Instantly share code, notes, and snippets.

@m-jovanovic
Created October 23, 2022 08:48

Revisions

  1. m-jovanovic created this gist Oct 23, 2022.
    58 changes: 58 additions & 0 deletions pipeline.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    name: Publish Development πŸš€

    on:
    workflow_dispatch:
    push:
    branches:
    - main

    env:
    AZURE_WEBAPP_NAME: dev-api-trainersphere
    AZURE_WEBAPP_PACKAGE_PATH: "./publish"
    DOTNET_VERSION: "6.0.x"
    CONNECTIONSTRINGS__DATABASE: "<Replaced by Bundle>"

    jobs:
    publish:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup .NET Core πŸ“¦
    uses: actions/setup-dotnet@v1
    with:
    dotnet-version: ${{ env.DOTNET_VERSION }}

    - name: Install dependencies πŸ› 
    run: dotnet restore ./src/App

    - name: Build 🧱
    run: dotnet build ./src/App --configuration Release --no-restore

    - name: Test πŸ§ͺ
    run: dotnet test ./src/App --configuration Release --no-build --verbosity normal

    - name: Install EF Tool πŸ¦„
    run: |
    dotnet new tool-manifest
    dotnet tool install dotnet-ef --version 6.0.3
    - name: Create migration bundles πŸ“¦
    run: |
    dotnet ef migrations bundle --configuration Bundle --verbose --startup-project ./src/App --project ./src/Modules/Users/Modules.Users.Persistence --context UsersDbContext --output users-bundle.exe
    dotnet ef migrations bundle --configuration Bundle --verbose --startup-project ./src/App --project ./src/Modules/Training/Modules.Training.Persistence --context TrainingDbContext --output training-bundle.exe
    dotnet ef migrations bundle --configuration Bundle --verbose --startup-project ./src/App --project ./src/Modules/Notifications/Modules.Notifications.Persistence --context NotificationsDbContext --output notifications-bundle.exe
    - name: Apply migration bundles πŸ“©
    run: |
    ./users-bundle.exe --connection '${{ secrets.DEV_CONNECTION_STRING }}' --verbose
    ./training-bundle.exe --connection '${{ secrets.DEV_CONNECTION_STRING }}' --verbose
    ./notifications-bundle.exe --connection '${{ secrets.DEV_CONNECTION_STRING }}' --verbose
    - name: Publish πŸš€
    run: dotnet publish ./src/App --configuration Release --no-build --output '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}'

    - name: Deploy to Azure 🌌
    uses: azure/webapps-deploy@v2
    with:
    app-name: ${{ env.AZURE_WEBAPP_NAME }}
    publish-profile: ${{ secrets.DEV_AZURE_PUBLISH_PROFILE }}
    package: "${{ env.AZURE_WEBAPP_PACKAGE_PATH }}"