diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index ff49c4e92..da6f3695a 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1,4 +1,4 @@ -name: Java CI with Gradle +name: Java CICD with Gradle on: push: @@ -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