From 3c2caf1d016e6e0e60a9a2980e6849332ecbfd8e Mon Sep 17 00:00:00 2001 From: thedrewen Date: Sun, 21 Sep 2025 15:37:06 +0200 Subject: [PATCH] Start deploy. --- .github/workflows/deploy.yml | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2b1fdfa --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +# This is a basic workflow to help you get started with Actions +name: Deploy + +# Controls when the workflow will run +on: + push: + branches: ['main'] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: Setup SSH Agent + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Add VPS to known_hosts + run: | + ssh-keyscan -p ${{ secrets.VPS_PORT }} -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts + + - name: Deploy to VPS + run: | + ssh -p ${{ secrets.VPS_PORT }} ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} " + cd /home/${{ secrets.VPS_USER }}/projects/hammer && + git pull && + + # Stop and remove old container if exists + docker stop hammer 2>/dev/null || true && + docker rm hammer 2>/dev/null || true && + + # Build new image + docker build -t hammer . && + + # Run new container + docker run -d \ + --restart unless-stopped \ + --name hammer \ + --network shared-network \ + hammer + " \ No newline at end of file