Skip to content

Commit

Permalink
[chore] cd 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
syyling committed Feb 15, 2024
1 parent 933592a commit 65dc375
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: ci
name: cd

on: [push]
on:
push:
branches:
- main

jobs:
build:
Expand All @@ -10,13 +13,13 @@ jobs:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/Setup-java@v4
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Gradle Caching
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -25,8 +28,42 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Make application-prod.yml
run: |
cd ./src/main/resources
touch ./application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml
shell: bash

- name: Grant Execute Permission For Gradlew
run: chmod +x gradlew

- name: Build With Gradle
run: ./gradlew build

- name: Docker build & push to docker repo
env:
DOCKER_PATH : .deploy/Dockerfile
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f $DOCKER_PATH -t ${{ secrets.DOCKER_REPO }}/mookive .
docker push ${{ secrets.DOCKER_REPO }}/mookive
- name: Deploy to Prob
uses: appleboy/ssh-action@master
id: deploy-prob
env:
DOCKER_COMPOSE : ".deploy/docker-compose.yml"
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_KEY }}
envs: GITHUB_SHA
script: |
touch ./docker-compose.yml
echo "${{ secrets.DOCKER_COMPOSE }}" > ./docker-compose.yml
docker stop mookive
docker rm mookive
docker pull ${{ secrets.DOCKER_REPO }}/mookive
docker-compose up -d
docker image prune

0 comments on commit 65dc375

Please sign in to comment.