53 lines (44 loc) · 1.53 KB
/
build-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: Build And Deploy
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c Release --no-restore
# Now build a linux publish
- name: Publish
run: dotnet publish -c Release -r linux-x64 -o "$GITHUB_WORKSPACE/publish" src/LightBlog.Server/LightBlog.Server.csproj
# Copying files and artifacts via SSH
- name: Copying files to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.SSH_KEY }}
rm: true
source: "publish/"
target: "/home/eliot/blog-deploy"
- name: Deploy on server
uses: garygrossgarten/github-action-ssh@release
with:
command: >
supervisorctl stop blog &&
rm -rf /var/blog/ &&
cp -a /home/eliot/blog-deploy/publish/. /var/blog/ &&
chown -R www-data /var/blog/ &&
supervisorctl start blog
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USER }}
privateKey: ${{ secrets.SSH_KEY }}