From ef593c771a29905ab47783ecf1648fe6973c07b9 Mon Sep 17 00:00:00 2001 From: alsdl0629 Date: Sat, 4 Nov 2023 22:46:31 +0900 Subject: [PATCH] =?UTF-8?q?Chore:=20(main)=20cd/cd=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 25 ++++++++++++++----------- .github/workflows/ci.yml | 10 +++++----- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3538f62..dd2be9d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -18,22 +18,25 @@ jobs: java-version: '17' distribution: 'zulu' - - name: Build with Gradle - run: ./gradlew build -x test + - name: Set up .jar + run: ./gradlew bootJar - - name: Deploy For EC2 # EC2 접속 + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@v5 + with: + name: ${{ secrets.DOCKER_REPOSITORY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Deploy For EC2 # EC2 ssh 접속 uses: appleboy/ssh-action@master with: host: ${{ secrets.EC2_HOST }} + port: ${{ secrets.EC2_SSH_PORT }} username: ${{ secrets.EC2_USERNAME }} key: ${{ secrets.EC2_SSH_KEY }} - port: ${{ secrets.EC2_SSH_PORT }} script: | cd sfe - git clone https://github.com/Survival-From-Epidemic/Survival-From-Epidemic-Backend.git - cd Survival-From-Epidemic-Backend/ - mkdir -p src/main/resources - echo "${{ secrets.MAIN_APPLICATION }}" | base64 --decode > src/main/resources/application.yml - touch .env - echo "${{ secrets.ENV }}" >> .env - docker-compose up -d \ No newline at end of file + docker pull ${{ secrets.DOCKER_REPOSITORY }} + docker rm -f sfe-server + docker run -dp ${SPRING_HOST_PORT}:${SPRING_CONTAINER_PORT} --name sfe-server --env-file .env ${{ secrets.DOCKER_REPOSITORY }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9b227e..8bdf82e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,8 @@ jobs: mkdir -p src/test/resources echo "${{ secrets.TEST_APPLICATION }}" | base64 --decode > src/test/resources/application.yml - - name: Build with Gradle -# uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 -# with: -# arguments: build - run: ./gradlew build -x test \ No newline at end of file + - name: run test + run: ./gradlew test + + - name: run build + run: ./gradlew clean build -x test \ No newline at end of file