From fc09472defd1e762273776b12d6cf3cafb519424 Mon Sep 17 00:00:00 2001 From: asn6878 Date: Sun, 2 Jun 2024 23:25:33 +0900 Subject: [PATCH] =?UTF-8?q?CD=20=ED=8C=8C=EC=9D=BC=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..1290aa2 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,63 @@ +name: Continuous Deployment + +on: + push: + branches: [ "main" ] + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + environment: + description: 'Environment to run tests against' + type: environment + required: false + +jobs: + deploy: + runs-on: ubuntu-22.04 + + steps: + # 1. Compare branch 코드 내려 받기 + - name: Checkout PR + uses: actions/checkout@v3 + with: + ref: ${{ github.event.push.base_ref }} + + # 2. 자바 환경 설정 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + # 3. Docker 이미지 build 및 push + - name: docker build and push + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t jinlee1703/likelion-12th-jwt-was:latest . + docker push jinlee1703/likelion-12th-jwt-was:latest + + # 5. SSH ACTION을 통한 Run-Command (Docker 이미지 pull 후 docker-compose를 통한 실행) + - name: ssh action + uses: appleboy/ssh-action@v0.1.5 + with: + host: ${{ secrets.SERVER_HOST }} + port: ${{ secrets.SERVER_SSH_PORT }} + username: ${{ secrets.SERVER_USERNAME }} + password: ${{ secrets.SERVER_PASSWORD }} + script: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker system prune -a -f + docker pull jinlee1703/likelion-12th-jwt-was:latest + docker-compose up -d \ No newline at end of file