From c0200f67f2cca405a388508148b49329d4b2d8ae Mon Sep 17 00:00:00 2001 From: Leander Furumo Date: Wed, 23 Oct 2024 16:48:23 +0200 Subject: [PATCH] add auto-deploy workflow hopefully it works. probably not knowing my luck --- .github/workflows/deploy.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 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..fb49818 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,24 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + run_pull: + runs-on: ubuntu-latest + + steps: + - name: Set up SSH + run: | + install -m 600 -D /dev/null ~/.ssh/id_ed25519 + echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 # This should be redundant but seems to do the trick. + ssh-keyscan -H ${{ secrets.SSH_HOST }} > ~/.ssh/known_hosts + + - name: Connect, pull, build and deploy + run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd ${{ secrets.WORK_DIR }} && git checkout ${{ secrets.MAIN_BRANCH }} && git pull && yarn build && exit" + + - name: Clean up + run: rm -rf ~/.ssh