diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..29253e9 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Build and Deploy CPRNIMS +on: + push: + branches: [ main ] + +jobs: + build-and-deploy: + runs-on: windows + steps: + - name: Checkout + uses: actions/checkout@v4 + + # ---- Build both .NET projects ---- + - name: Publish WebApi + run: dotnet publish .\CPRNIMS.WebApi\CPRNIMS.WebApi.csproj -c Release -o D:\ci-output\webapi + shell: pwsh + + - name: Publish WebApps + run: dotnet publish .\CPRNIMS.WebApps\CPRNIMS.WebApps.csproj -c Release -o D:\ci-output\webapps + shell: pwsh + + # ---- Deploy to IIS server over SSH ---- + - name: Stop app pools + run: | + ssh -i D:\gitea-runner\deploy_key lliadmin@212.47.72.54 "Import-Module WebAdministration; Stop-WebAppPool -Name 'CPRNIMS-Api'; Stop-WebAppPool -Name 'CPRNIMS-Web'; Start-Sleep -Seconds 3" + shell: pwsh + + - name: Copy WebApi + run: scp -i D:\gitea-runner\deploy_key -r D:\ci-output\webapi\* lliadmin@212.47.72.54:C:/inetpub/cprnims-api/ + shell: pwsh + + - name: Copy WebApps + run: scp -i D:\gitea-runner\deploy_key -r D:\ci-output\webapps\* lliadmin@212.47.72.54:C:/inetpub/cprnims-web/ + shell: pwsh + + - name: Start app pools + run: | + ssh -i D:\gitea-runner\deploy_key lliadmin@212.47.72.54 "Import-Module WebAdministration; Start-WebAppPool -Name 'CPRNIMS-Api'; Start-WebAppPool -Name 'CPRNIMS-Web'" + shell: pwsh \ No newline at end of file