I struggled with building this pipeline a bit so I thought I would share the process

1. Create Blazor APP and Digitalocean droplet

I created new Blazor Web Assembly project in Visual studio using the Dotnet Core hosted model.

In Digitalocean I used the smallest and cheapest $5 Ubuntu 18 droplet and set up Nginx manualy.

2. Create Github Actions Template to your Blazor project

name: .NET Core

    branches: [ master ]

    runs-on: ubuntu-latest
    - uses: actions/checkout@v2
    - name: Setup .NET Core
      uses: actions/setup-dotnet@v1
        dotnet-version: 3.1.300-preview-015135
    - name: Build
      run: dotnet build --configuration Release
    - name: dotnet publish 
      run: |
        dotnet publish --configuration Release -o myapp
    - name: Push to Digital Ocean
      uses: appleboy/scp-action@master
        host: ${{ secrets.REMOTE_HOST }}
        username: ${{ secrets.REMOTE_USER }}
        port: ${{ secrets.REMOTE_PORT }}
        password: ${{ secrets.PASSWORD }}
        source: "myapp"
		rm: true
        target: "/var/www/myapp"

This action will build the project with your specified Dotnet core version(I used 3.1 preview here) and then copy it to your remote target.

Btw these ${{ secrets.PASSWORD }} must be added to your Github account so they can be accessed.

3. Add Github to known hosts on your server

  • Get Github host with this command ssh-keyscan -t rsa github.com | tee github-key-temp | ssh-keygen -lf - You would get something like this:
    2048 SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 github.com (RSA)

Add this to your servers ~/.ssh/known_hosts file

4. Allow log in with password and give write permissions for /var/www

run `sudo chmod g+w /var/www/`
run `sudo nano /etc/ssh/sshd_config` and change `PasswordAuthentication yes`
restart ssh service:
`service ssh stop`
`service ssh start`

5. Push to master and your Blazor project should now build and then be copied to your remote server

Github actions