File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy downpatch.com
2+
3+ on :
4+ push :
5+ branches : ["main"]
6+ workflow_dispatch : {}
7+
8+ concurrency :
9+ group : downpatch-deploy
10+ cancel-in-progress : true
11+
12+ jobs :
13+ deploy :
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Setup .NET
20+ uses : actions/setup-dotnet@v4
21+ with :
22+ dotnet-version : " 10.0.x"
23+
24+ - name : Restore
25+ run : dotnet restore ./downpatch.csproj
26+
27+ - name : Publish
28+ run : dotnet publish ./downpatch.csproj -c Release -o ./out --no-restore
29+
30+ - name : Configure SSH
31+ shell : bash
32+ run : |
33+ set -euo pipefail
34+ mkdir -p ~/.ssh
35+ echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
36+ chmod 600 ~/.ssh/id_ed25519
37+ ssh-keyscan -p "${{ secrets.SSH_PORT }}" "${{ secrets.SSH_HOST }}" >> ~/.ssh/known_hosts
38+
39+ - name : Upload release via rsync
40+ shell : bash
41+ run : |
42+ set -euo pipefail
43+ RELEASE="${{ github.sha }}"
44+ rsync -az --delete \
45+ -e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/id_ed25519" \
46+ ./out/ "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/var/www/downpatch/releases/${RELEASE}/"
47+
48+ - name : Activate release + restart service
49+ shell : bash
50+ run : |
51+ set -euo pipefail
52+ RELEASE="${{ github.sha }}"
53+ ssh -p "${{ secrets.SSH_PORT }}" -i ~/.ssh/id_ed25519 "${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}" bash -lc " \
54+ set -euo pipefail; \
55+ ln -sfn /var/www/downpatch/releases/${RELEASE} /var/www/downpatch/current; \
56+ sudo /bin/systemctl restart downpatch.service; \
57+ sudo /bin/systemctl status downpatch.service --no-pager \
58+ "
You can’t perform that action at this time.
0 commit comments