Merge pull request #51 from ConnectCo/fix/#50/웹소켓-연결-오류-수정 #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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: ConnectCO Dev Deploy | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Build를 위한 JDK 설치 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# 체크아웃 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# application.yml 생성 | |
- name: Create application.yml | |
run: | | |
pushd ./src/main | |
mkdir -p resources | |
cd resources | |
touch application.yml | |
echo "${{ secrets.YML }}" >> application.yml | |
popd | |
# 빌드 (test 제외) | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
## 도커 이미지 빌드 후 push하기 | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPO }} . | |
docker push ${{ secrets.DOCKER_REPO }} | |
# EC2 배포 | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
sudo docker rm -f $(docker ps -qa) | |
sudo docker pull ${{ secrets.DOCKER_REPO }} | |
docker-compose up -d | |
docker image prune -f |