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
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
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
with:
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`