-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (70 loc) · 2.52 KB
/
click-service-cd.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
name: cd for click-service
on:
pull_request:
branches: [ main ]
paths:
- click-service/**
- .github/workflows/click-service-cd.yml
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
REGION: ${{ secrets.REGION }}
WORKSTATION_IMAGE: click-service
VERSION: '1.0.2'
IMAGE: ${{ secrets.REGION }}-docker.pkg.dev/${{ secrets.PROJECT_ID }}/${{ secrets.DOCKER_REPO }}/click-service
REDIS_HOST: ${{secrets.REDIS_HOST}}
REDIS_PORT: ${{secrets.REDIS_PORT}}
DATASOURCE_URL: ${{secrets.DB_URL}}
DATASOURCE_USERNAME: ${{secrets.DB_USERNAME}}
DATASOURCE_PASSWORD: ${{secrets.DB_PASSWORD}}
GRAFANA_ADMIN_USER: ${{ secrets.GRAFANA_ADMIN_USER }}
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out Repository
uses: actions/checkout@v3
- name: Cache Gradle caches
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ github.job}}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-${{ github.job }}
- name: Cache Jib layers
uses: actions/cache@v3
with:
path: ./click-service/build/jib-cache
key: ${{ runner.os }}-jib-${{ github.job }}-${{ hashFiles('**/build.gradle') }}
restore-keys: ${{ runner.os }}-jib-${{ github.job }}
- name: Set up google auth
id: 'auth'
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCE_SA_KEY }}
- id: 'get-credentials'
uses: google-github-actions/get-gke-credentials@v1
with:
cluster_name: cluster-1
location: ${{ env.REGION }}-a
- name: Docker auth
run: |-
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Docker Build
run: ./gradlew :click-service:jib
- name: Apply Persistent Volumes
run: |
kubectl apply -f ./click-service/pv.yaml
kubectl apply -f ./click-service/pvc.yaml
- name: Deploy
run: |
sed "s,\${image},${{ env.IMAGE }},g" ./click-service/resources.yaml > deployment.yaml
kubectl apply -f ./deployment.yaml
kubectl apply -f ./click-service/hpa.yaml