From 1f82b59a384cf9b7ee85bc003c6dca12f411ff61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ru=C3=A1n=20Murgatroyd?= Date: Thu, 28 Mar 2024 23:30:12 +0000 Subject: [PATCH] Added new workflow --- .github/workflows/deploy-to-vps.yaml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/deploy-to-vps.yaml diff --git a/.github/workflows/deploy-to-vps.yaml b/.github/workflows/deploy-to-vps.yaml new file mode 100644 index 0000000..b850c32 --- /dev/null +++ b/.github/workflows/deploy-to-vps.yaml @@ -0,0 +1,32 @@ +name: Deploy Website to VPS + +on: + push: + branches: + - master + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Setup SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Build and Deploy with Docker Compose + env: + EXPOSED_PORT: ${{ secrets.EXPOSED_PORT }} + run: | + ssh -o StrictHostKeyChecking=no ${{ secrets.USERNAME }}@${{ secrets.HOST }} << 'EOF' + cd /src/csppStaticSite + + # Pull the latest changes + git pull origin master + + # Use Docker Compose to rebuild and restart the container with the new image + EXPOSED_PORT=${EXPOSED_PORT} docker-compose up -d --build + EOF