Skip to content

Commit

Permalink
Update dev_deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
m3k0813 authored Jul 7, 2024
1 parent 1ccccf1 commit 70393b0
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,22 @@ jobs:
if: contains(github.ref, 'develop')
run: ./gradlew build -x test

# docker build & push to production
- name: Docker build & push to prod
if: contains(github.ref, 'dev')
# Spring 어플리케이션 Docker Image 빌드
- name: Build Docker Image For Spring
run: |
echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
docker build -f Dockerfile -t ${{ secrets.DOCKER_REPO }} .
docker push ${{ secrets.DOCKER_REPO }}
# deploy to production
- name: Deploy to prod
uses: appleboy/[email protected]
id: deploy-prod
if: contains(github.ref, 'develop')
docker login -u ${{ secrets.DOCKER_REPO }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_REPO }}/도커 레파지토리 이름 .
docker push ${{ secrets.DOCKER_REPO }}/도커 레파지토리 이름
# 서버에서 Docker 이미지 실행
- name: EC2 Docker Run
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST}}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_SSH_PRIVATE_KEY }}
port: 22
envs: GITHUB_SHA
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_KEY }}
script: |
echo test1234 > test.txt
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_REPO }}
docker rm -f $(docker ps -qa)
docker rmi ${{ secrets.DOCKER_REPO }}/도커 레파지토리 이름
docker pull ${{ secrets.DOCKER_REPO }}/도커 레파지토리 이름
docker-compose up -d
docker image prune -f

0 comments on commit 70393b0

Please sign in to comment.