-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (64 loc) · 1.98 KB
/
main.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
name: Deploy Arithmetic Calculator Solution
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: calculator
MYSQL_USER: ${{ secrets.DB_USERNAME }}
MYSQL_PASSWORD: ${{ secrets.DB_PASSWORD }}
options: >-
--health-cmd="mysqladmin ping --silent"
--health-interval=10s
--health-timeout=5s
--health-retries=3
volumes:
- mysql-data:/var/lib/mysql
steps:
- name: Cache MySQL Data
id: cache-mysql-data
uses: actions/cache@v2
with:
path: /var/lib/mysql
key: mysql-data-${{ github.run_id }}
restore-keys: |
mysql-data-
- name: Checkout Spring Boot Repository
uses: actions/checkout@v2
with:
repository: encouver/calculator-api
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Install Maven
run: |
sudo apt-get update
sudo apt-get install -y maven
- name: Build with Maven
run: |
mvn clean install
- name: Deploy Spring Boot Application
env:
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/calculator
SPRING_DATASOURCE_USERNAME: ${{ secrets.DB_USERNAME }}
SPRING_DATASOURCE_PASSWORD: ${{ secrets.DB_PASSWORD }}
JWT_SECRET: ${{ secrets.JWT_SECRET }}
run: |
java -jar target/calculator-1.0.0.jar &
- name: Trigger React Deployment
run: |
curl -X POST -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/encouver/calculator-ui/dispatches \
-d '{"event_type":"deploy"}'