Skip to content

Merge pull request #78 from Solution-Challenge-stress-solution/dev_kyko #112

Merge pull request #78 from Solution-Challenge-stress-solution/dev_kyko

Merge pull request #78 from Solution-Challenge-stress-solution/dev_kyko #112

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: Deploy
#on:
# push:
# branches: [ "dev_joon" ]
# pull_request:
# branches: [ "main" ]
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
# 기본 체크아웃
- name: Checkout
uses: actions/checkout@v3
# Gradlew 실행 허용
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
# JDK 17 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# 환경 변수 설정
# - name: Set environment values
# run: |
# cd ./src/main/resources
# touch ./env.properties
# echo "${{ secrets.ENV }}" > ./env.properties
# shell: bash
# Gradle build (Test 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: clean build -x test
# Docker 이미지 빌드
- name: Docker build & push to Docker repo
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
echo "docker 로그인 성공"
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/strecording .
echo "docker 빌드 성공"
docker push ${{ secrets.DOCKERHUB_USERNAME }}/strecording
- name: Build and Deploy
uses: appleboy/ssh-action@master
with:
host: 34.64.90.112
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
envs: GITHUB_SHA
script: |
sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
echo "docker 로그인 성공"
sudo docker stop $(sudo docker ps -aq)
echo "현재 실행 중인 모든 Docker 컨테이너 중지"
sudo docker rm -f $(sudo docker ps -qa)
echo "모든 Docker 컨테이너 강제로 삭제"
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/strecording
echo "docker pull 성공"
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/strecording