Add automatic deployment
Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
8fbd3356c0
commit
9f9ff93c97
3 changed files with 97 additions and 1 deletions
91
.forgejo/workflows/push.yml
Normal file
91
.forgejo/workflows/push.yml
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
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 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}}
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,2 +1,6 @@
|
||||||
.idea/
|
.idea/
|
||||||
.venv/
|
.venv/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
__pycache__/
|
||||||
|
*.spec
|
1
main.py
1
main.py
|
@ -4,6 +4,7 @@ import client
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from next.ext.commands import DefaultHelpCommand
|
from next.ext.commands import DefaultHelpCommand
|
||||||
|
from sys import exit
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
Loading…
Reference in a new issue