forked from TechPrimers/docker-mysql-spring-boot-example
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (50 loc) · 1.91 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
name: Build
on: [push]
env:
MYSQL_REPLICA_COUNT: 2
MYSQL_USER: sa
MYSQL_PASS: ${{ secrets.MYSQL_PASS }}
MYSQL_DB: test
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Build and Push the Docker image
run: |
docker build . --file Dockerfile --tag ${{ secrets.DOCKER_HUB_USER }}/docker-mysql-spring-boot-example:$GITHUB_SHA
docker login --username ${{ secrets.DOCKER_HUB_USER }} --password ${{ secrets.DOCKER_HUB_PASS }}
docker push ${{ secrets.DOCKER_HUB_USER }}/docker-mysql-spring-boot-example:$GITHUB_SHA
deploy_mysql:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Deploy Mysql
uses: WyriHaximus/[email protected]
with:
exec: |
helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
helm repo update
helm upgrade --install --wait mysql incubator/mysqlha \
--set fullnameOverride=mysql,mysqlha.replicaCount=$MYSQL_REPLICA_COUNT,mysqlha.mysqlUser=$MYSQL_USER,mysqlha.mysqlDatabase=$MYSQL_DB,mysqlha.mysqlPassword=$MYSQL_PASS,mysqlImage=mysql:5.7
kubeconfig: '${{ secrets.KUBE_CONFIG_DATA }}'
deploy_app:
runs-on: ubuntu-latest
needs:
- deploy_mysql
- build
steps:
- uses: actions/checkout@v1
- name: Deploy Spring app
uses: WyriHaximus/[email protected]
with:
exec: |
helm upgrade --install spring-app ./kubernetes/spring-app \
--set image.imageName=${{ secrets.DOCKER_HUB_USER }}/docker-mysql-spring-boot-example:$GITHUB_SHA,envVars.MYSQL_USER=$MYSQL_USER,envVars.MYSQL_PASS=$MYSQL_PASS,envVars.MYSQL_DB=$MYSQL_DB
kubeconfig: '${{ secrets.KUBE_CONFIG_DATA }}'