-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (39 loc) · 1.44 KB
/
deploy.yml
File metadata and controls
39 lines (39 loc) · 1.44 KB
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
name: Deploy
on:
push:
branches:
- 'master'
jobs:
deploy:
name: "Deploy to production"
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Setup ssh
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/key
chmod 600 ~/.ssh/key
cat >>~/.ssh/config << END
Host prod
HostName $SSH_HOST
User $SSH_USER
Port $SSH_PORT
IdentityFile ~/.ssh/key
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_KEY: ${{ secrets.SSH_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_PORT: ${{ secrets.SSH_PORT }}
- name: Cloning repository
run: ssh prod 'cd botsdediscordbot && git fetch && git reset --hard origin/master'
- name: Building container
run: ssh prod 'bash -i -c "cd botsdediscordbot && docker build --cpuset-cpus=0 --memory="512m" . -t botsdediscord/bot"'
- name: Stopping container
run: ssh prod 'bash -i -c "docker rm --force botsdediscordbot"'
- name: Starting container
run: ssh prod 'bash -i -c "docker run --network=adg-network --add-host=mongoservice:172.18.0.1 -d --restart always --cpuset-cpus=0-5 --memory="512m" --name botsdediscordbot botsdediscord/bot"'
- name: Clear cache
run: ssh prod 'bash -i -c "docker system prune -f"'