From 6473bd7f3375dcfb482173c50083f47036688f3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=89=9B=E6=8C=AF=E6=B4=8B?= <54138779+ZYNORl@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:38:54 +0800 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 733fbcf..7881c8b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Build Docker Images + - name: Build Docker Images! run: | docker-compose -f docker-compose.yml build @@ -31,13 +31,13 @@ jobs: sudo apt-get update sudo apt-get install -y sshpass - - name: Connect Docker on Ubuntu Server and remove previously useless images! + - name: Connect Docker on Ubuntu Server! env: SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} SERVER_IP: ${{ secrets.SSH_HOST }} SSH_USER: ${{ secrets.SSH_USER }} run: | - sshpass -p "${SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SERVER_IP} "docker image prune" + sshpass -p "${SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SERVER_IP} "docker version" - name: Push images to Docker Repository! @@ -50,3 +50,11 @@ jobs: docker save petplanet-pet-image:latest | gzip | sshpass -p "${SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SERVER_IP} "gzip -d | docker load" docker save petplanet-post-image:latest | gzip | sshpass -p "${SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SERVER_IP} "gzip -d | docker load" docker save petplanet-user-image:latest | gzip | sshpass -p "${SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SERVER_IP} "gzip -d | docker load" + + - name: Remove previously useless images!!! + env: + SSH_PASSWORD: ${{ secrets.SSH_PASSWORD }} + SERVER_IP: ${{ secrets.SSH_HOST }} + SSH_USER: ${{ secrets.SSH_USER }} + run: | + sshpass -p "${SSH_PASSWORD}" ssh -o StrictHostKeyChecking=no ${SSH_USER}@${SERVER_IP} "docker image prune"