-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (56 loc) · 1.7 KB
/
build-push.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
54
55
56
57
58
59
60
61
62
63
64
name: "Publish and deploy"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ "master" ]
jobs:
upload-solution:
name: Upload Octobot to production
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Publish solution
run: dotnet publish $PUBLISH_FLAGS
env:
PUBLISH_FLAGS: ${{vars.PUBLISH_FLAGS}}
- name: Setup SSH key
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
ssh-keyscan -H $SSH_HOST > ~/.ssh/known_hosts
shell: bash
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
SSH_HOST: ${{secrets.SSH_HOST}}
- name: Stop currently running instance
run: |
ssh $SSH_USER@$SSH_HOST $STOP_COMMAND
shell: bash
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
STOP_COMMAND: ${{vars.STOP_COMMAND}}
- name: Upload published solution
run: |
scp -r $UPLOAD_FROM $SSH_USER@$SSH_HOST:$UPLOAD_TO
shell: bash
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
UPLOAD_FROM: ${{vars.UPLOAD_FROM}}
UPLOAD_TO: ${{vars.UPLOAD_TO}}
- name: Start new instance
run: |
ssh $SSH_USER@$SSH_HOST $START_COMMAND
shell: bash
env:
SSH_USER: ${{secrets.SSH_USER}}
SSH_HOST: ${{secrets.SSH_HOST}}
START_COMMAND: ${{vars.START_COMMAND}}