-
Notifications
You must be signed in to change notification settings - Fork 4
73 lines (59 loc) · 2.07 KB
/
dev_ci_cd.yml
File metadata and controls
73 lines (59 loc) · 2.07 KB
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
name: Build and Deploy To Dev Environment
on:
push:
branches:
- dev
jobs:
build_and_deploy:
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ secrets.DEV_DOCKERHUB_USERNAME }}/newzet-spring-server
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
credentials_json: '${{ secrets.DEV_GCP_SERVICE_ACCOUNT_KEY }}'
- name: Set up gcloud CLI
uses: google-github-actions/setup-gcloud@v2
with:
project_id: eminent-ember-468115-i1
- name: Download New Relic Files from GCS
run: |
mkdir -p newrelic
gsutil cp gs://newzet-dev-st/newrelic.jar ./newrelic/newrelic.jar
gsutil cp gs://newzet-dev-st/newrelic.yml ./newrelic/newrelic.yml
- name: Gradle Caching
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DEV_DOCKERHUB_USERNAME }}
password: ${{ secrets.DEV_DOCKERHUB_TOKEN }}
- name: Build and push Docker image
run: |
docker build -t $IMAGE_NAME:latest --build-arg JAR_FILE=build/libs/*.jar .
docker push $IMAGE_NAME:latest
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
- name: Deploy to VM
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.DEV_SSH_USER }}@${{ secrets.DEV_SSH_HOST }} \
"cd /home/jiho99322/app && bash ./deploy.sh ${{ github.sha }}"