From c922f4ecacb12125db4f1e0259a6886850ea3be5 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Wed, 17 Apr 2024 01:26:47 -0400 Subject: [PATCH] add step to deploy docker image to droplet --- .github/workflows/deploy.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a3d9e81..3da5ed1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,3 +27,19 @@ jobs: with: push: true tags: ${{ secrets.DOCKER_USERNAME}}/${{ secrets.DOCKER_REPOSITORY }}:latest + + - name: Deploy to DO + uses: appleboy/ssh-action@v1.0.3 + env: + IMAGE_PATH: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest + APP_NAME: ${{ secrets.DOCKER_REPOSITORY }} + PORT: ${{ secrets.PORT }} + with: + host: ${{ secrets.DO_HOST }} + username: ${{ secrets.DO_USERNAME }} + key: ${{ secrets.DO_KEY }} + script: | + docker image pull $IMAGE_PATH + docker container stop $APP_NAME + docker container rm $APP_NAME + docker container run -d --name $APP_NAME -p $PORT:$PORT $IMAGE_PATH