Skip to content

Merge branch 'main' of https://github.com/Chat-ITC/WithYou #124

Merge branch 'main' of https://github.com/Chat-ITC/WithYou

Merge branch 'main' of https://github.com/Chat-ITC/WithYou #124

Workflow file for this run

name: CICD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- uses: actions/checkout@v3
- name: Make application-dev.yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.PROPERTIES }}" > src/main/resources/application-dev.yml
find src
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Build with Gradle
run: ./gradlew build
shell: bash
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_ID }} -p ${{ secrets.DOCKER_PW }}
docker build --progress plain -t ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_IMAGE_NAME }} .
docker push ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_IMAGE_NAME }}
# 도커 이미지를 빌드하고, 로그인 한 후 푸시합니다.
- name: EC2 Deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
script: |
docker stop withyou_cd
docker rm withyou_cd
docker pull ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_IMAGE_NAME }}
docker run -d --name withyou_cd -p 8080:8080 ${{ secrets.DOCKER_ID }}/${{ secrets.DOCKER_IMAGE_NAME }}
# EC2 인스턴스로 SSH 연결하여 도커 이미지를 풀링하고 컨테이너를 생성합니다.