-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (66 loc) · 2.23 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
name: cd for click-service
on:
push:
branches: [ "main" ]
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
DOCKER_REPO: ${{ secrets.DOCKER_REPO }}
REGION: ${{ secrets.REGION }}
WORKSTATION_IMAGE: click-service
VERSION: '1.0.0'
jobs:
build:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./click-service
steps:
- name: Check out Repository
uses: actions/checkout@v3
- name: Set Kubernetes Yaml
uses: microsoft/variable-substitution@v1
with:
files: ./resources.yaml
env:
image: ${{env.REGION}}-docker.pkg.dev/${{env.PROJECT_ID}}/${{env.DOCKER_REPO}}/${{env.WORKSTATION_IMAGE}}
spec.template.spec.containers.image: ${{env.image}}
- name: Set Application Yml
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application-prod.yml
env:
spring.data.redis.host: ${{secrets.REDIS_HOST}}
spring.data.redis.port: ${{secrets.REDIS_PORT}}
spring.datasource.url: ${{secrets.DB_URL}}
spring.datasource.username: ${{secrets.DB_USERNAME}}
spring.datasource.password: ${{secrets.DB_PASSWORD}}
spec.template.spec.containers.image: ${{env.image}}
- 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: autopilot-cluster-1
location: ${{env.REGION}}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ env.PROJECT_ID }}
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '17'
- name: Run tests
run: ../gradlew test
- name: Docker Build
if: success()
run: ../gradlew docker
- name: Docker tag
run: docker tag click-me-${{env.WORKSTATION_IMAGE}}:${env.VERSION} ${{env.image}}
- name: Docker Push
run: docker push ${{env.image}}
- name: Deploy
run: kubectl apply -f ./resources.yaml