Deploying site to Umbhost using Github Actions
# help-with-umbraco
s
Hey all, I've been trying to deploy a site - via Guthub Actions - but I keep running into errors. Here is the .yml file (all of the secrets have been set within the repo)
Copy code
name: Build, publish and deploy project to UmbHost

on:
  push:
    branches: [ main ]
env:
    SolutionName: ${{ secrets.SOLUTION_NAME }}
    BuildPlatform: Any CPU
    BuildConfiguration: Release

jobs:
  build:

    runs-on: windows-latest
    
    steps:
        - name: Checkout
          uses: actions/checkout@v3.0.0

        - name: Create Build Directory
          run: mkdir _build

        - name: Build Solution
          run: | 
            dotnet build ${{env.SolutionName}} /nologo /nr:false /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DeleteExistingFiles=True /p:SkipInvalidConfigurations=true /p:IncludeSetAclProviderOnDestination=False /p:AutoParameterizationWebConfigConnectionStrings=False /p:platform="${{env.BuildPlatform}}" /p:configuration="${{env.BuildConfiguration}}" /p:PackageLocation="../_build"
            
        - name: Deploy to UmbHost
          uses: UmbHost/umbhost-web-deploy@v1.0.3
          with:
            website-name: ${{ secrets.WEBSITE_NAME }}
            server-computer-name: ${{ secrets.SERVER_COMPUTER_NAME }}
            server-username: ${{ secrets.USERNAME }}
            server-password: ${{ secrets.PASSWORD }}
            source-path: '_build'
            source-fileName: Umbraco.Web.zip
Which runs into this error:
Copy code
Run UmbHost/umbhost-web-deploy@v1.0.3
Run D:\a\_actions\UmbHost\umbhost-web-deploy\v1.0.3/Scripts/Set-ApplicationPool.ps1 -recycleMode StopAppPool -recycleApp *** -computerName *** -username ***
Error: Unrecognized argument '"-dest:recycleApp=***,recycleMode=StopAppPool,computerName=***/MsDeploy.axd?site=***,username=\"***\",***"***\",AuthType=\"Basic\""'. All arguments must begin with "-".
Error count: 1.
Error: Process completed with exit code 1.
n
At a guess I would say either your username or another value has a - or a space in it which might be braking the parameters
c
Have a look at package script writer GitHub actions to see if it helps. It is also hosted on umbhost. https://github.com/prjseal/Package-Script-Writer/blob/main/.github/workflows/main.yml
d
I have UmBootstrap publishing to UmbHost using GitHub Actions - @AaronSadlerUK very kindly wrote the YAML for me - perhaps he can help?
a
@User Please downgrade and use version 1.0.1 The latest version has a bug, sorry about that!
Copy code
name: Build, publish and deploy project to UmbHost

on:
  push:
    branches: [ main ]
env:
    SolutionName: ${{ secrets.SOLUTION_NAME }}
    BuildPlatform: Any CPU
    BuildConfiguration: Release

jobs:
  build:

    runs-on: windows-latest
    
    steps:
        - name: Checkout
          uses: actions/checkout@v3.0.0

        - name: Create Build Directory
          run: mkdir _build

        - name: Build Solution
          run: | 
            dotnet build ${{env.SolutionName}} /nologo /nr:false /p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:DeleteExistingFiles=True /p:SkipInvalidConfigurations=true /p:IncludeSetAclProviderOnDestination=False /p:AutoParameterizationWebConfigConnectionStrings=False /p:platform="${{env.BuildPlatform}}" /p:configuration="${{env.BuildConfiguration}}" /p:PackageLocation="../_build"
            
        - name: Deploy to UmbHost
          uses: UmbHost/umbhost-web-deploy@v1.0.1
          with:
            website-name: ${{ secrets.WEBSITE_NAME }}
            server-computer-name: ${{ secrets.SERVER_COMPUTER_NAME }}
            server-username: ${{ secrets.USERNAME }}
            server-password: ${{ secrets.PASSWORD }}
            source-path: '_build'
            source-fileName: Umbraco.Web.zip
s
Thanks all, this has got the deployment working! However, I've run into an issue where, because my generated models were committed to the repo (and therefore the server), there are duplicate models, which Umbraco in complaining about. I've tried removing them, but that breaks my build because there are references to the models in some Extensions and things like that. Any suggestions?
a
In your appsettings.Production.json file you can set the models builder mode to "Nothing", this will stop the duplicated models error. You will need to modify your dotnet build command to set the environment name, you can add the below to the end of the line
/p:EnvironmentName=Production
s
Hey again, just wanted to say a big thank you, that has got it working! @AaronSadlerUK
9 Views