This repository was archived by the owner on Dec 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (120 loc) · 4.49 KB
/
deploy-application.yaml
File metadata and controls
128 lines (120 loc) · 4.49 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Build and deploy application
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-backend:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./backend
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Build with Maven
run: mvn clean install
- name: Build and publish backend Docker image to Github Packages Registry
uses: elgohr/Publish-Docker-Github-Action@v4
env:
FIREBASE_CREDENTIALS: ${{ secrets.FIREBASE_CREDENTIALS }}
with:
context: backend
name: wojberni/interactive-learning/interactive-learning-backend
registry: ghcr.io
username: ${{ secrets.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
buildargs: FIREBASE_CREDENTIALS
dockerfile: ./backend/Dockerfile
tags: latest
build-mobile-web:
needs: build-backend
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./mobile
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.3.4'
- run: flutter --version
- run: flutter pub get
- run: flutter pub upgrade learning_api
- name: Build web application
run: flutter build web
- name: Build and publish backend Docker image to Github Packages Registry
uses: elgohr/Publish-Docker-Github-Action@v4
with:
context: mobile
name: wojberni/interactive-learning/interactive-learning-mobile-web
registry: ghcr.io
username: ${{ secrets.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
dockerfile: ./mobile/Dockerfile
tags: latest
deploy-backend:
needs: build-backend
runs-on: ubuntu-latest
steps:
- name: Deploy image to server
uses: appleboy/ssh-action@master
env:
GITHUB_USERNAME: ${{ secrets.USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
with:
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
envs: GITHUB_USERNAME, GITHUB_TOKEN, DB_URL, DB_USERNAME, DB_PASSWORD, JWT_SECRET
script: |
docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN
docker pull ghcr.io/wojberni/interactive-learning/interactive-learning-backend:latest
docker stop interactive-learning-backend
docker system prune -f --volumes
docker run --name interactive-learning-backend \
-e APP_DATABASE_URL=$DB_URL -e APP_DATABASE_USERNAME=$DB_USERNAME -e APP_DATABASE_PASSWORD=$DB_PASSWORD -e APP_JWT_TOKEN_SECRET=$JWT_SECRET \
-dit -p 8080:8080 ghcr.io/wojberni/interactive-learning/interactive-learning-backend:latest
deploy-mobile-web:
needs: build-mobile-web
runs-on: ubuntu-latest
steps:
- name: Deploy image to server
uses: appleboy/ssh-action@master
env:
GITHUB_USERNAME: ${{ secrets.USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DB_URL: ${{ secrets.DB_URL }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
with:
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
envs: GITHUB_USERNAME, GITHUB_TOKEN
script: |
docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN
docker pull ghcr.io/wojberni/interactive-learning/interactive-learning-mobile-web:latest
docker stop interactive-learning-mobile-web
docker system prune -f --volumes
docker run --name interactive-learning-mobile-web \
-dit -p 2137:80 ghcr.io/wojberni/interactive-learning/interactive-learning-mobile-web:latest