Skip to content

Commit

Permalink
chore: ci cd prd 설정 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
seong-wooo authored Sep 24, 2023
1 parent 3b50894 commit 89c1884
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build-docker-image-prd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build Backend Image Prd

on:
workflow_call:
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_PASSWORD:
required: true
PRD_DOCKER_AUTHENTICATION_IMAGE_NAME:
required: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

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

- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Build with jib
run: ./gradlew jib --image="${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PRD_DOCKER_AUTHENTICATION_IMAGE_NAME }}"
32 changes: 32 additions & 0 deletions .github/workflows/cd-prd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name : cd - prd

on:
push:
branches:
- main

jobs:
build-back-docker-img:
uses: ./.github/workflows/build-docker-image-prd.yml
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
PRD_DOCKER_AUTHENTICATION_IMAGE_NAME: ${{ secrets.PRD_DOCKER_AUTHENTICATION_IMAGE_NAME }}

deploy:
needs: build-back-docker-img
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PRD_HOST }}
username: ${{ secrets.PRD_HOST_USER_NAME }}
key: ${{ secrets.PRD_PRIVATE_KEY }}
script: |
cd ${{ secrets.PRD_DEPLOY_DIRECTORY }}
docker compose stop ${{ secrets.PRD_DOCKER_AUTHENTICATION_CONTAINER_NAME }}
docker compose rm -f ${{ secrets.PRD_DOCKER_AUTHENTICATION_CONTAINER_NAME }}
docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PRD_DOCKER_AUTHENTICATION_IMAGE_NAME }}
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PRD_DOCKER_AUTHENTICATION_IMAGE_NAME }}
docker compose up -d

0 comments on commit 89c1884

Please sign in to comment.