Vijay Pratap Singh

Vijay Pratap Singh

  • 342
  • 4.6k
  • 378.8k

GitHub Action not creating publish folder and not updating dll's.

Jun 28 2023 8:51 AM

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


Answers (1)