-
-
Notifications
You must be signed in to change notification settings - Fork 4
52 lines (42 loc) · 2 KB
/
build-api-prod.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
name: build-api-prod
on:
workflow_dispatch:
push:
tags:
- releases/[0-9]+.[0-9]+.[0-9]+
- releases/[0-9]+.[0-9]+.[0-9]+.[0-9]+
- prereleases/[0-9]+.[0-9]+.[0-9]+
- prereleases/[0-9]+.[0-9]+.[0-9]+.[0-9]+
paths-ignore:
- site/**
- src/RoadCaptain.App.Runner/** # Don't trigger on Runner only changes
- src/RoadCaptain.App.RouteBuilder/** # Don't trigger on RouteBuilder only changes
jobs:
build_api_linux-x64:
runs-on: ubuntu-latest
env:
CONFIGURATION: Release
RID: linux-x64
ZIP_FILE: roadcaptain-app-web-prod-${{ github.sha }}.tar.gz
steps:
- uses: actions/checkout@v3
- name: Publish API
# Because of reasons we need to explicitly set RuntimeIdentifiers to only win-x64 because MSBuild sets it to osx-x64;win-x64
run: dotnet publish --no-self-contained -c ${{ env.CONFIGURATION }} -r ${{ env.RID }} -p:RuntimeIdentifiers=${{ env.RID }} src/RoadCaptain.App.Web/RoadCaptain.App.Web.csproj
- name: Create ZIP archive
run: tar -zcf "${{ github.workspace }}/${{ env.ZIP_FILE }}" *
working-directory: src/RoadCaptain.App.Web/bin/${{ env.CONFIGURATION }}/net6.0/linux-x64/publish
- name: Setup SSH key
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_SITE_KEY }}"
- name: Copy artifacts to server
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: scp -r -o "StrictHostKeyChecking no" "${{ github.workspace }}/${{ env.ZIP_FILE }}" roadcaptain@roadcaptain.nl:/opt/roadcaptain/${{ env.ZIP_FILE }}
- name: Extract artifacts on server
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: ssh -o "StrictHostKeyChecking no" roadcaptain@roadcaptain.nl 'systemctl stop --user RoadCaptainApiProd; cd /opt/roadcaptain/api-prod; tar -zxf /opt/roadcaptain/${{ env.ZIP_FILE }}; systemctl start --user RoadCaptainApiProd; rm -f /opt/roadcaptain/roadcaptain-app-web-prod-*.tar.gz'