From d19ee85675f23eabad3391f09be9f7a408d47e9f Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Sat, 22 Feb 2025 23:33:00 -0700 Subject: [PATCH] FEAT: What are the odds this works --- .github/deploy.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/deploy.yml diff --git a/.github/deploy.yml b/.github/deploy.yml new file mode 100644 index 0000000..ff97165 --- /dev/null +++ b/.github/deploy.yml @@ -0,0 +1,35 @@ +name: Deploy to Server + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: . + file: ./Dockerfile + push: true + tags: azpect3120/hhargreaves.dev:latest + + - name: Deploy to server via SSH + uses: appleboy/ghaction-ssh@master + with: + host: ${{ secrets.SERVER_IP }} # Server IP address + username: ${{ secrets.SERVER_USERNAME }} # Server username + key: ${{ secrets.SERVER_PRIVATE_KEY }} # Server private key (base64 encoded) + port: ${{ secrets.SERVER_PORT || 22 }} # SSH port (default 22) + script: | + docker pull azpect3120/hhargreaves.dev:latest # Pull the latest image + docker stop hhargreaves.dev || true # Stop the old container (ignore if it doesn't exist) + docker rm hhargreaves.dev || true # Remove the old container (ignore if it doesn't exist) + docker run -d -p 3000:3000 --name hhargreaves.dev azpect3120/hhargreaves.dev:latest # Run the new container