Skip to content

[chore] deploy.yml 작성 #1

[chore] deploy.yml 작성

[chore] deploy.yml 작성 #1

Workflow file for this run

name: CD
on:
push:
branches: [ main ]
pull_request:
branches:
- main
- test
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
tags:
description: 'Test scenario tags'
required: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: 저장소 Checkout
uses: actions/checkout@v3
- name: 스프링부트 애플리케이션 빌드 # (1)
run: ./gradlew build
- name: 도커 이미지 빌드 # (2)
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest .
- name: Docker Hub 로그인 # (3)
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Docker Hub 퍼블리시 # (4)
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
- name: WAS 인스턴스 접속 및 애플리케이션 실행 # (5)
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_SSH_HOST }}
username: ${{ secrets.AWS_SSH_USERNAME }}
key: ${{ secrets.AWS_SSH_KEY }}
port: ${{ secrets.AWS_SSH_PORT }}
script: |
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
docker run -d -p 8080:8080 --name rebing-wonderful ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest