From 576d108b3b05d852794ca5c66a4a0ebaf26e7029 Mon Sep 17 00:00:00 2001 From: Vitaliy Potyarkin Date: Thu, 29 Aug 2024 12:59:14 +0300 Subject: [PATCH] [#25] Deploy the site via SSH Signed-off-by: Vitaliy Potyarkin --- .forgejo/workflows/build.yml | 33 ++++++++++++++++++++++----------- Makefile | 5 +++++ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 772733b..bcb1786 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -30,15 +30,26 @@ jobs: rm -rf themes/dot-hugo make all - - uses: https://code.forgejo.org/forgejo/upload-artifact@v4 - id: artifact-upload-step - with: - name: site - path: | - public/ - if-no-files-found: error - retention-days: 10 - - - name: Show artifact URL + - name: Setup SSH environment + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.socket run: | - echo 'Download URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}' + umask 0077 + mkdir -p ~/.ssh/ + ssh-keyscan frostfs.info >> ~/.ssh/known_hosts + ssh-keygen -A # create host keys + ssh-agent -a "$SSH_AUTH_SOCK" + echo "${{ secrets.SSH_DEPLOY_KEY }}" > ~/.ssh/key + stat ~/.ssh/key + ssh-keygen -y -f ~/.ssh/key + ssh-add ~/.ssh/key + rm ~/.ssh/key + + - name: make deploy + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + run: | + ssh-add -L + make deploy + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.socket diff --git a/Makefile b/Makefile index 39709a7..0dea43e 100644 --- a/Makefile +++ b/Makefile @@ -27,3 +27,8 @@ server: submodules $(HUGO_BIN) submodules: @git submodule init @git submodule update --recursive --remote + +.PHONY: deploy +deploy: + test -f public/index.html + cd public && tar --gzip --create . | ssh deploy@frostfs.info frostfs.info