From ed894637d3167b3a4cdf191521bd18ebe3b9095f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EA=B8=B0=ED=83=9C?= <91439717+kitaee@users.noreply.github.com> Date: Tue, 7 Jan 2025 00:20:45 +0900 Subject: [PATCH] =?UTF-8?q?=08chore:=20CI/CD=EB=A5=BC=20=EC=9C=84=ED=95=9C?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gradle.yml | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/gradle.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml new file mode 100644 index 0000000..5906116 --- /dev/null +++ b/.github/workflows/gradle.yml @@ -0,0 +1,51 @@ +name: CD with Gradle + +on: + push: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: "adopt" + + - name: Make application.yml + run: | + cd ./src/main/resources + touch ./application.yml + echo "${{ secrets.DATABASE }}" > ./application.yml + shell: bash + + - name: Build with Gradle + run: | + chmod +x ./gradlew + ./gradlew clean build -x test + + - name: Docker build & push to docker repo + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }}/directors-dev . + docker push ${{ secrets.DOCKER_REPO }}/directors-dev + + - name: Deploy to server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ubuntu + key: ${{ secrets.KEY }} + script: | + sudo docker rm -f $(docker ps -qa) + sudo docker pull ${{ secrets.DOCKER_REPO }}/directors-dev + docker-compose up -d + docker image prune -f