I have successfully built the pipeline in GitHub actions, which is also building successfully on each push in the master branch. But these above commands are not making publish folder and neither can I get DLLs. It means this is working fine but my code is not getting updated on the success build.
name: ASP.NET Core Web API Deploy
on:
push:
branches:
- master
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x # or the version you're using
- name: Create publish folder
run: |
mkdir ./publish
- name: Check workspace contents
run: |
ls -R ${{ github.workspace }}
- name: Build and publish
run: dotnet publish -c Release -o ./publish
- name: Verify build output
run: |
ls -R ./publish
- name: Create zip file
run: |
$publishFolder = "${{ github.workspace }}/publish"
$zipFile = "${{ github.workspace }}/publish.zip"
Compress-Archive -Path $publishFolder -DestinationPath $zipFile
- name: Stop IIS Website
run: |
Import-Module WebAdministration
Stop-WebSite -Name "practicecicdgithub" -ErrorAction SilentlyContinue
- name: Deploy to IIS
run: |
$publishFolder = "${{ github.workspace }}/publish"
$siteName = "practicecicdgithub"
$destinationFolder = "D:\PublishPracticeAPIs"
# Copy published files to the target folder
Copy-Item -Path $publishFolder -Destination $destinationFolder -Recurse -Force
# Verify copied files
ls -R $destinationFolder
# Import the WebAdministration module
Import-Module WebAdministration
# Create a new website
New-WebApplication -Name $siteName -Site 'Default Web Site' -PhysicalPath $destinationFolder
- name: Recycle application pool
run: |
$appPoolName = "DefaultAppPool" # Replace with the name of your application pool
Invoke-Command -ScriptBlock { Import-Module WebAdministration; Restart-WebAppPool -Name $args[0] } -ArgumentList $appPoolName
I have already verified the build output and copied files this is giving me the path that I am unable to find in my local system. I see that it is not creating any folder of the publish dlls.
It shows me this directory which is not even available in my system but getting published successfully.
Directory: D:\a\PracticeCICDGithub\PracticeCICDGithub\publish


Brahma Prakash ShuklaPosted Jun 28, 2023, 11:35 AM
It seems that the build and publish steps are configured correctly. However, there might be a few things you can check to ensure the expected behavior:
Verify the correct file path: Make sure you are looking for the publish folder and DLLs in the correct location on your local system. In the provided workflow, the publish folder is created relative to the GitHub workspace (
./publish). If you're looking for the files on your local system, they should be in the same directory where you run the workflow.Check the publish output: After running the
dotnet publishcommand, the publish output should be available in the./publishdirectory within the GitHub Actions runner environment. You can add a step after the build and publish step to verify the contents of the./publishdirectory using thelscommand.Confirm the copy destination: In the "Deploy to IIS" step, the
$destinationFoldervariable specifies the destination path for copying the published files. Double-check that this destination folder (D:\PublishPracticeAPIs) is correct and accessible on your local system.Inspect the GitHub Actions logs: During the workflow run, check the logs and output generated by the workflow steps. This can help identify any errors or unexpected behavior that may be occurring.
By reviewing these aspects, you should be able to determine if the issue lies in the workflow configuration or if there's a misinterpretation of the file paths.