Skip to content

Commit

Permalink
Merge pull request #55 from TelePigeon/feat/52
Browse files Browse the repository at this point in the history
[feat] #52 CD.yml 생성
  • Loading branch information
tkdwns414 authored Jun 4, 2024
2 parents 6f3d563 + 0e72c7e commit 5470922
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CD

on:
push:
branches: [ "develop" ]

jobs:
CI:
runs-on: ubuntu-latest

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

- name: create secret config file
run: |
cd src/main/resources
echo "${{ secrets.APPLICATION }}" > ./application.yml
- name: Set up Docker Buildx
uses: docker/[email protected]

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

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.REPONAME }}

CD:
needs: [CI]
runs-on: ubuntu-latest

steps:
- name: Docker Image Pull and Container Run
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.SERVER_KEY }}
script: |
cd ~
./deploy.sh
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM gradle:8.5-jdk17 AS builder
COPY . /usr/src
WORKDIR /usr/src
RUN gradle wrapper --gradle-version 8.5
RUN ./gradlew clean build -x test

FROM openjdk:17-jdk-alpine
COPY --from=builder /usr/src/build/libs/server-0.0.1-SNAPSHOT.jar /usr/app/app.jar
ENTRYPOINT ["java", "-jar", "/usr/app/app.jar"]

0 comments on commit 5470922

Please sign in to comment.