Skip to content

Commit e6b330b

Browse files
authored
Merge pull request #16 from LISA-ITMO/practika-develop
Deployment configured and caching added
2 parents a2c1dc0 + a47572b commit e6b330b

17 files changed

Lines changed: 155 additions & 485 deletions

.env.example

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ JWT_REFRESH_SECRET=change_me_refresh
1111
# Telegram bot
1212
TG_BOT_TOKEN=123456:ABC-DEF
1313
TEACHER_CODE=SECRET
14-
15-
# Platform address used by bot to create links (inside docker-compose use web service)
16-
PLATFORM_ADDRESS=http://web:80
14+
PLATFORM_ADDRESS_SERVER=http://server:3000
15+
PLATFORM_ADDRESS_CLIENT=http://localhost:8080
1716

1817
# CORS
1918
CORS_ORIGIN=*

.github/workflows/DEV.yml

Lines changed: 0 additions & 170 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/practika.yml

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,125 @@ name: Build and Publish
22

33
on:
44
push:
5-
branches: [ "practika-develop" ]
5+
branches: ["practika-develop", "develop"]
66

77
jobs:
88
build-server:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v3
13-
11+
- uses: actions/checkout@v4
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v3
1414
- name: Login to Docker Hub
15-
uses: docker/login-action@v2
15+
uses: docker/login-action@v3
1616
with:
1717
username: ${{ secrets.DOCKER_USERNAME }}
1818
password: ${{ secrets.DOCKER_PASSWORD }}
19-
2019
- name: Build and Push Server
21-
uses: docker/build-push-action@v4
20+
uses: docker/build-push-action@v5
2221
with:
2322
context: ./server
2423
push: true
2524
tags: ${{ secrets.DOCKER_USERNAME }}/eduplatform-server:latest
25+
cache-from: type=gha
26+
cache-to: type=gha,mode=max
2627

2728
build-web:
29+
needs: build-server
2830
runs-on: ubuntu-latest
2931
steps:
30-
- name: Checkout code
31-
uses: actions/checkout@v3
32-
32+
- uses: actions/checkout@v4
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
3335
- name: Login to Docker Hub
34-
uses: docker/login-action@v2
36+
uses: docker/login-action@v3
3537
with:
3638
username: ${{ secrets.DOCKER_USERNAME }}
3739
password: ${{ secrets.DOCKER_PASSWORD }}
38-
3940
- name: Build and Push Web
40-
uses: docker/build-push-action@v4
41+
uses: docker/build-push-action@v5
4142
with:
4243
context: ./frontend
4344
file: frontend/packages/web/Dockerfile
4445
push: true
4546
tags: ${{ secrets.DOCKER_USERNAME }}/eduplatform-web:latest
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max
4649

4750
build-admin:
51+
needs: build-web
4852
runs-on: ubuntu-latest
4953
steps:
50-
- name: Checkout code
51-
uses: actions/checkout@v3
52-
54+
- uses: actions/checkout@v4
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
5357
- name: Login to Docker Hub
54-
uses: docker/login-action@v2
58+
uses: docker/login-action@v3
5559
with:
5660
username: ${{ secrets.DOCKER_USERNAME }}
5761
password: ${{ secrets.DOCKER_PASSWORD }}
58-
5962
- name: Build and Push Admin
60-
uses: docker/build-push-action@v4
63+
uses: docker/build-push-action@v5
6164
with:
6265
context: ./frontend
6366
file: frontend/packages/admin/Dockerfile
6467
push: true
65-
tags: ${{ secrets.DOCKER_USERNAME }}/eduplatform-admin:latest
68+
tags: ${{ secrets.DOCKER_USERNAME }}/eduplatform-admin:latest
69+
cache-from: type=gha
70+
cache-to: type=gha,mode=max
71+
72+
build-tgbot:
73+
needs: build-admin
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
- name: Set up Docker Buildx
78+
uses: docker/setup-buildx-action@v3
79+
- name: Login to Docker Hub
80+
uses: docker/login-action@v3
81+
with:
82+
username: ${{ secrets.DOCKER_USERNAME }}
83+
password: ${{ secrets.DOCKER_PASSWORD }}
84+
- name: Build and Push Bot
85+
uses: docker/build-push-action@v5
86+
with:
87+
context: ./tgbot
88+
push: true
89+
tags: ${{ secrets.DOCKER_USERNAME }}/eduplatform-tgbot:latest
90+
cache-from: type=gha
91+
cache-to: type=gha,mode=max
92+
93+
deploy-to-new-vm:
94+
needs: build-tgbot
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout repo
98+
uses: actions/checkout@v4
99+
- name: Copy compose via ssh
100+
uses: appleboy/scp-action@master
101+
with:
102+
host: ${{ secrets.HOST }}
103+
username: ${{ secrets.USER }}
104+
password: ${{ secrets.SSH_PASSPHRASE }}
105+
source: "docker-compose.yml"
106+
target: "eduplatform/"
107+
- name: Deploy via SSH
108+
uses: appleboy/ssh-action@master
109+
with:
110+
host: ${{ secrets.HOST }}
111+
username: ${{ secrets.USER }}
112+
password: ${{ secrets.SSH_PASSPHRASE }}
113+
script: |
114+
cd ~/eduplatform
115+
116+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
117+
118+
export DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}
119+
120+
docker compose down || true
121+
122+
docker compose pull
123+
124+
docker compose up -d --remove-orphans
125+
126+
docker system prune -af

0 commit comments

Comments
 (0)