Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] cd 수정 #4

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading