Create dad-mehrPublish
This commit is contained in:
67
.github/workflows/dad-mehrPublish
vendored
Normal file
67
.github/workflows/dad-mehrPublish
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
name: Build & Deploy .NET App to IIS
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
# ===================== CHECKOUT CODE =====================
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# ===================== SETUP .NET SDK =====================
|
||||
- name: Setup .NET SDK
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
# ===================== RESTORE DEPENDENCIES =====================
|
||||
- name: Restore dependencies
|
||||
run: dotnet restore
|
||||
|
||||
# ===================== BUILD PROJECT =====================
|
||||
- name: Build Project
|
||||
run: dotnet build --configuration Release
|
||||
|
||||
# ===================== PUBLISH PROJECT =====================
|
||||
- name: Publish Project
|
||||
shell: powershell
|
||||
run: |
|
||||
$publishFolder = "$(System.DefaultWorkingDirectory)\publish"
|
||||
Write-Host "Publishing to folder: $publishFolder"
|
||||
dotnet publish --configuration Release --output "$publishFolder" --no-build /p:EnvironmentName=Production
|
||||
|
||||
# ===================== DEPLOY TO IIS SERVER =====================
|
||||
- name: Deploy to IIS via Web Deploy
|
||||
shell: powershell
|
||||
env:
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||
REMOTE_PASS: ${{ secrets.REMOTE_PASS }}
|
||||
run: |
|
||||
$publishFolder = Resolve-Path "./publish"
|
||||
$siteName = "dad-mehr"
|
||||
$destinationPath = "C:\inetpub\wwwroot\dad-mehr"
|
||||
|
||||
Write-Host "Stopping IIS site $siteName ..."
|
||||
& "C:\Windows\System32\inetsrv\appcmd.exe" stop site "$siteName" | Out-Null
|
||||
|
||||
Write-Host "Deploying to $destinationPath ..."
|
||||
& "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" `
|
||||
-verb:sync `
|
||||
-source:contentPath="$publishFolder" `
|
||||
-dest:contentPath="$destinationPath",computerName="https://${{ env.REMOTE_HOST }}:8172/msdeploy.axd?site=$siteName",userName="${{ env.REMOTE_USER }}",password="${{ env.REMOTE_PASS }}",authType="Basic" `
|
||||
-allowUntrusted `
|
||||
-enableRule:DoNotDeleteRule `
|
||||
-enableRule:AppOffline `
|
||||
-usechecksum
|
||||
|
||||
Write-Host "Starting IIS site $siteName ..."
|
||||
& "C:\Windows\System32\inetsrv\appcmd.exe" start site "$siteName" | Out-Null
|
||||
|
||||
Write-Host "✅ Deployment completed successfully."
|
||||
Reference in New Issue
Block a user