Skip to content

Commit

Permalink
fix: github runner 재설치
Browse files Browse the repository at this point in the history
  • Loading branch information
sleeg00 committed Apr 29, 2024
1 parent ef29173 commit 95e633b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,40 +57,37 @@ jobs: #작업을 정의

# 3. Docker 이미지 빌드
- name: docker image build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/just .
run: docker build -t 0.0.0.0:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest .

# 4. DockerHub 로그인
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name : docker tag
run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/just ${{ secrets.DOCKERHUB_USERNAME }}/just:latest

# 5. Docker Hub 이미지 푸시
- name: docker Hub push
run: docker push {{ secrets.DOCKERHUB_USERNAME }}/just:latest
run: docker push 0.0.0.0:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest
#
run-docker-image-on-ec2:
# build-docker-image (위)과정이 완료되어야 실행됩니다.
needs: build-docker-image
runs-on: self-hosted

steps:
- name: docker rmi
run: docker rmi 0.0.0.0:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest
# 1. 최신 이미지를 풀받습니다
- name: docker pull
run: sudo docker pull {{ secrets.DOCKERHUB_USERNAME }}/just:latest
run: sudo docker pull 0.0.0.0:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest

# 2. 기존의 컨테이너를 중지시킵니다
- name: docker stop container
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true

# 3. 최신 이미지를 컨테이너화하여 실행시킵니다
- name: docker run new container
run: sudo docker run --name just --rm -d -p 9000:9000 ${{ secrets.DOCKERHUB_USERNAME }}/just:latest
run: sudo docker run 0.0.0.0:5000/${{ secrets.DOCKERHUB_USERNAME }}/just:latest

# 4. 미사용 이미지를 정리합니다
- name: delete old docker image
run: sudo docker system prune -f

0 comments on commit 95e633b

Please sign in to comment.