Skip to content
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 }}
- 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: 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