From 7eba632f1c057407c7da73332668d16bce32060b Mon Sep 17 00:00:00 2001 From: Mahan Chamani <109232147+mahanch@users.noreply.github.com> Date: Sat, 22 Nov 2025 13:31:47 +0330 Subject: [PATCH 1/4] Refactor .NET workflow to use project-specific commands Updated the .NET GitHub Actions workflow to specify project files for restore, build, and publish steps. Replaced hardcoded credentials with GitHub secrets for deployment. --- .github/workflows/dotnet-developPublish.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index aace164d..ddb25830 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -19,16 +19,15 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@v4 with: - dotnet-version: '8.0.x' # یا نسخه پروژه‌ت + dotnet-version: '8.0.x' - name: Restore dependencies - run: dotnet restore - + run: dotnet restore ServiceHost/ServiceHost.csproj - name: Build - run: dotnet build --configuration Release + run: dotnet build ServiceHost/ServiceHost.csproj --configuration Release - name: Publish - run: dotnet publish --configuration Release --output ./publish /p:EnvironmentName=Development --no-build + run: dotnet publish ServiceHost/ServiceHost.csproj --configuration Release --output ./publish /p:EnvironmentName=Development --no-build - name: Deploy to IIS via Web Deploy shell: powershell @@ -37,12 +36,6 @@ jobs: & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` -verb:sync ` -source:contentPath="$publishFolder" ` - -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" ` + -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="${{ secrets.DEPLOY_USER }}",password="${{ secrets.DEPLOY_PASSWORD }}",authType="Basic" ` -allowUntrusted ` -enableRule:AppOffline - - - env: - SERVER_HOST: your-server-ip-or-domain - DEPLOY_USER: ${{ secrets.DEPLOY_USER }} - DEPLOY_PASSWORD: ${{ secrets.DEPLOY_PASSWORD }} From cb08e11593f214ea63bebca7b176a6c9aa4f0129 Mon Sep 17 00:00:00 2001 From: Mahan Chamani <109232147+mahanch@users.noreply.github.com> Date: Sat, 22 Nov 2025 13:42:25 +0330 Subject: [PATCH 2/4] Refactor IIS deployment step in workflow --- .github/workflows/dotnet-developPublish.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index ddb25830..957f30c8 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -29,13 +29,9 @@ jobs: - name: Publish run: dotnet publish ServiceHost/ServiceHost.csproj --configuration Release --output ./publish /p:EnvironmentName=Development --no-build - - name: Deploy to IIS via Web Deploy + - name: Deploy to IIS via Web Deploy shell: powershell run: | - $publishFolder = Resolve-Path ./publish - & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` - -verb:sync ` - -source:contentPath="$publishFolder" ` - -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="${{ secrets.DEPLOY_USER }}",password="${{ secrets.DEPLOY_PASSWORD }}",authType="Basic" ` - -allowUntrusted ` - -enableRule:AppOffline + $publishFolder = Resolve-Path ./publish & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" + -verb:sync + -source:contentPath="$publishFolder" -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" -allowUntrusted -enableRule:AppOffline From 62349c0a54e2e79e4654a8bcc0e33bf90379ac76 Mon Sep 17 00:00:00 2001 From: Mahan Chamani <109232147+mahanch@users.noreply.github.com> Date: Sat, 22 Nov 2025 14:01:16 +0330 Subject: [PATCH 3/4] Refactor Web Deploy command for better readability --- .github/workflows/dotnet-developPublish.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index 957f30c8..25835387 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -32,6 +32,11 @@ jobs: - name: Deploy to IIS via Web Deploy shell: powershell run: | - $publishFolder = Resolve-Path ./publish & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" - -verb:sync - -source:contentPath="$publishFolder" -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" -allowUntrusted -enableRule:AppOffline + $publishFolder = Resolve-Path ./publish + & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` + -verb:sync ` + -source:contentPath="$publishFolder" ` + -dest:contentPath="C:\inetpub\wwwroot\dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" ` + -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" ` + -allowUntrusted ` + -enableRule:AppOffline From 0fe0c05e5cf09c015cf579f0017ead8ad9b2b424 Mon Sep 17 00:00:00 2001 From: Mahan Chamani <109232147+mahanch@users.noreply.github.com> Date: Sat, 22 Nov 2025 14:44:20 +0330 Subject: [PATCH 4/4] Fix destination path in deployment script --- .github/workflows/dotnet-developPublish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dotnet-developPublish.yml b/.github/workflows/dotnet-developPublish.yml index 25835387..37566664 100644 --- a/.github/workflows/dotnet-developPublish.yml +++ b/.github/workflows/dotnet-developPublish.yml @@ -36,7 +36,6 @@ jobs: & "C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" ` -verb:sync ` -source:contentPath="$publishFolder" ` - -dest:contentPath="C:\inetpub\wwwroot\dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" ` -dest:contentPath="dadmehrg",computerName="https://171.22.24.15:8172/msdeploy.axd?site=dadmehrg",userName="Administrator",password="R2rNpdnetP3j>q5b18",authType="Basic" ` -allowUntrusted ` -enableRule:AppOffline