Skip to content

Commit

Permalink
docker hub에 업로드된 이미지 pull 받고 실행하도록 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Curry4182 authored Jan 9, 2024
1 parent 840dcb9 commit d13a71e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java CI with Gradle
name: Java CICD with Gradle

on:
push:
Expand Down Expand Up @@ -36,3 +36,20 @@ jobs:

- name: docker Hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/lime-image

run-docker-image-on-server:
needs: build-docker-image
runs-on: self-hosted

steps:
- name: docker pull
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo

- name: docker stop container
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true

- name: docker run new container
run: sudo docker run --name github-actions-demo --rm -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo

- name: delete old docker image
run: sudo docker system prune -f

0 comments on commit d13a71e

Please sign in to comment.