fix database #176
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: Build, publish and deploy to MonsterASP.NET | |
| on: [push] | |
| jobs: | |
| build_and_deploy: | |
| runs-on: windows-latest | |
| env: | |
| ADMIN_EMAIL: "${{ secrets.ADMIN_EMAIL }}" | |
| ADMIN_PASSWORD: "${{ secrets.ADMIN_PASSWORD }}" | |
| Jwt__Key: "${{ secrets.JWT_KEY }}" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET 8 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0 | |
| - name: Install dependencies | |
| run: cd RegMan.Backend.API && dotnet restore | |
| - name: Install EF Core tools | |
| run: dotnet tool install --global dotnet-ef --version 8.* | |
| - name: Add .NET tools to PATH | |
| shell: pwsh | |
| run: echo "$env:USERPROFILE\.dotnet\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Apply Database Migrations | |
| run: cd RegMan.Backend.API && dotnet ef database update --connection "${{ secrets.CONNECTION_STRING }}" | |
| - name: Build | |
| run: cd RegMan.Backend.API && dotnet build --configuration Release --no-restore | |
| - name: Publish | |
| run: cd RegMan.Backend.API && dotnet publish --configuration Release --output ./publish --runtime win-x86 --self-contained false | |
| - name: List published files | |
| run: Get-ChildItem -Recurse "RegMan.Backend.API/publish/" | Select-Object FullName | |
| shell: pwsh | |
| - name: Update appsettings with connection string | |
| run: | | |
| $appSettings = Get-Content "RegMan.Backend.API/publish/appsettings.json" | ConvertFrom-Json | |
| $appSettings.ConnectionStrings.DefaultConnection = "${{ secrets.CONNECTION_STRING }}" | |
| $appSettings | ConvertTo-Json -Depth 10 | Set-Content "RegMan.Backend.API/publish/appsettings.json" | |
| shell: pwsh | |
| - name: Test with .NET | |
| run: cd RegMan.Backend.API && dotnet test | |
| - name: Deploy to MonsterASP.NET via WebDeploy | |
| uses: rasmusbuchholdt/[email protected] | |
| with: | |
| website-name: ${{ secrets.WEBSITE_NAME }} | |
| server-computer-name: ${{ secrets.SERVER_COMPUTER_NAME }} | |
| server-username: ${{ secrets.SERVER_USERNAME }} | |
| server-password: ${{ secrets.SERVER_PASSWORD }} | |
| source-path: "RegMan.Backend.API/publish/" |