From c31b41a6fddfbad6889a39c5529a78dde3dd80b6 Mon Sep 17 00:00:00 2001 From: mctaylors Date: Wed, 6 Nov 2024 22:32:51 +0300 Subject: [PATCH] Add automatic deployment Signed-off-by: mctaylors --- .forgejo/workflows/push.yml | 99 +++++++++++++++++++++++++ .gitignore | 5 +- __pycache__/client.cpython-312.pyc | Bin 0 -> 7125 bytes __pycache__/extensions.cpython-312.pyc | Bin 0 -> 456 bytes main.py | 1 + 5 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 .forgejo/workflows/push.yml create mode 100644 __pycache__/client.cpython-312.pyc create mode 100644 __pycache__/extensions.cpython-312.pyc diff --git a/.forgejo/workflows/push.yml b/.forgejo/workflows/push.yml new file mode 100644 index 0000000..9f72272 --- /dev/null +++ b/.forgejo/workflows/push.yml @@ -0,0 +1,99 @@ +name: Update production + +on: + push: + branches: + - master + +jobs: + build-upload-artifact: + name: Build and upload Lurker as artifact + runs-on: docker + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Python 3.13 + uses: actions/setup-python@v5 + with: + python-version: '3.13' + cache: 'pip' + env: + AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache + + - name: Setup virtual environment + run: python -m venv .venv/ + + - name: Install necessary packages using pip + run: ./.venv/bin/pip install $PIP_PACKAGES + env: + PIP_PACKAGES: ${{vars.PIP_PACKAGES}} + + - name: Build binary + run: ./.venv/bin/pyinstaller $PYINSTALLER_FLAGS main.py + env: + PYINSTALLER_FLAGS: ${{vars.PYINSTALLER_FLAGS}} + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: lurker-bin + path: dist/ + + update-production: + name: Update Lurker on production + runs-on: docker + + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: lurker-bin + + - name: Copy SSH key + run: | + install -m 600 -D /dev/null ~/.ssh/id_ed25519 + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 + shell: bash + env: + SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}} + + - name: Generate SSH known hosts file + run: | + ssh-keyscan -H -p $SSH_PORT $SSH_HOST > ~/.ssh/known_hosts + shell: bash + env: + SSH_HOST: ${{secrets.SSH_HOST}} + SSH_PORT: ${{secrets.SSH_PORT}} + + - name: Stop currently running instance + run: | + ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $STOP_COMMAND + shell: bash + env: + SSH_PORT: ${{secrets.SSH_PORT}} + SSH_USER: ${{secrets.SSH_USER}} + SSH_HOST: ${{secrets.SSH_HOST}} + STOP_COMMAND: ${{vars.STOP_COMMAND}} + + - name: Upload artifact + run: | + scp -r -P $SSH_PORT $UPLOAD_FROM $SSH_USER@$SSH_HOST:$UPLOAD_TO + shell: bash + env: + SSH_PORT: ${{secrets.SSH_PORT}} + SSH_USER: ${{secrets.SSH_USER}} + SSH_HOST: ${{secrets.SSH_HOST}} + UPLOAD_FROM: ${{vars.UPLOAD_FROM}} + UPLOAD_TO: ${{vars.UPLOAD_TO}} + + - name: Start new instance + run: | + ssh -p $SSH_PORT $SSH_USER@$SSH_HOST $START_COMMAND + shell: bash + env: + SSH_PORT: ${{secrets.SSH_PORT}} + SSH_USER: ${{secrets.SSH_USER}} + SSH_HOST: ${{secrets.SSH_HOST}} + START_COMMAND: ${{vars.START_COMMAND}} diff --git a/.gitignore b/.gitignore index 3e8ecb4..e40e3cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ .idea/ -.venv/ \ No newline at end of file +.venv/ +build/ +dist/ +*.spec \ No newline at end of file diff --git a/__pycache__/client.cpython-312.pyc b/__pycache__/client.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..34012e1c39bd90d95142a1e1a27179192b97b11e GIT binary patch literal 7125 zcmb_hYit`=cE0l@DN-*|loZL5M^B5QM7^w+_3%2BEGLn*w&OUl(m`y#Vi=d+xdCKIWYBojd%O^71kS)FgFxIz9^@hX zXi-2m1pd{-8yePVsc{f>bT$p|be)}e5TIBs#1p^3(Se)Yy`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