-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (73 loc) · 2.8 KB
/
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Deploy
on:
push:
branches: main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout del repository
uses: actions/checkout@v2
- name: Set ENV variables
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV
- name: Clone or update repository
id: clone_or_update_repo
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
script: |
if [ ! -d "/etc/docker/tester" ]; then
git clone --recursive https://leoBitto:${{ secrets.GITHUB_TOKEN }}@github.com/leoBitto/tester.git /etc/docker/tester
else
cd /etc/docker/tester
git pull --recurse-submodules origin main
fi
- name: Create config directory and .env file
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
script: |
mkdir -p config
echo "DEBUG=False" >> config/.env
echo "SECRET_KEY=foo" >> config/.env
echo "DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] *" >> config/.env
echo "SQL_ENGINE=django.db.backends.postgresql" >> config/.env
echo "POSTGRES_DB=${{ secrets.POSTGRES_DB }}" >> config/.env
echo "POSTGRES_USER=${{ secrets.POSTGRES_USER }}" >> config/.env
echo "POSTGRES_PASSWORD=${{ secrets.POSTGRES_PASSWORD }}" >> config/.env
echo "SQL_HOST=db" >> config/.env
echo "SQL_PORT=5432" >> config/.env
echo "DATABASE=postgres" >> config/.env
echo "DOMAIN=localhost" >> config/.env
pwd
ls -la
cat ./config/.env
- name: Upgrade server and install docker and stop old container
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
script: |
sudo apt update -y
sudo apt upgrade -y
sudo apt install docker-ce docker-ce-cli containerd.io -y
sudo apt install docker-compose -y
cd /etc/docker
docker-compose down || true
- name: Avvia i nuovi container
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.DO_SSH_PRIVATE_KEY }}
script: |
cd /etc/docker
docker-compose down || true
docker-compose up -d