-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
21 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 |