Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ jobs:
deploy:
runs-on: ubuntu-latest
env: # Or as an environment variable
JBOND_BOT_TOKEN: ${{ secrets.JBOND_BOT_TOKEN }}
BRANCH: master
DIRECTORY: /opt/jbond
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -25,31 +26,28 @@ jobs:
run: |
python3 -m ensurepip
pip3 install aiogram
- name: Pull code
uses: appleboy/[email protected]
with:
host: ${{ secrets.JBOND_SSH_HOST }}
username: ${{ secrets.JBOND_SSH_USER }}
password: ${{ secrets.JBOND_SSH_PASS }}
#private_key: ${{ secrets.JBOND_SSH_PRIVATE_KEY }}
script: |
cd /opt
git clone https://github.com/andrevis/jbond.git
cd jbond
git checkout master
git pull origin master
- name: Install
uses: appleboy/[email protected]
with:
host: ${{ secrets.JBOND_SSH_HOST }}
username: ${{ secrets.JBOND_SSH_USER }}
password: ${{ secrets.JBOND_SSH_PASS }}
#private_key: ${{ secrets.JBOND_SSH_PRIVATE_KEY }}
script: |
systemctl stop jbond.service
systemctl disable jbond.service
cp -f /opt/jbond/misc/jbond.service /usr/lib/systemd/system/
systemctl daemon-reload
systemctl enable jbond.service
cp -f /opt/jbond/misc/jbond_logrotate /etc/logrotate.d/
systemctl restart crond
- name: install ssh keys
# check this thread to understand why its needed:
# <https://stackoverflow.com/a/70447517>
run: |
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.JBOND_SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
cat ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.JBOND_SSH_HOST }} > ~/.ssh/known_hosts
- name: clone
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "rm -rf $DIRECTORY && git clone https://github.com/andrevis/jbond.git $DIRECTORY"
- name: checkout-pull
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "cd $DIRECTORY && git checkout $BRANCH && git pull origin $BRANCH"
- name: stop service
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "systemctl stop jbond.service && systemctl disable jbond.service"
- name: set token
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "echo ${{ secrets.JBOND_BOT_TOKEN }} > $DIRECTORY/token"
- name: setup service
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "cp -f $DIRECTORY/misc/jbond.service /usr/lib/systemd/system/"
- name: enable service
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "systemctl daemon-reload && systemctl enable jbond.service && systemctl restart jbond.service"
- name: setup logrotate
run: ssh ${{ secrets.JBOND_SSH_USER }}@${{ secrets.JBOND_SSH_HOST }} "cp -f $DIRECTORY/misc/jbond_logrotate /etc/logrotate.d/ && systemctl restart crond"
- name: cleanup keys
if: always()
run: rm -rf ~/.ssh/id_rsa
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
token
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -174,9 +175,9 @@ cython_debug/
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the enitre vscode folder
# .vscode/

Expand Down
26 changes: 2 additions & 24 deletions src/jbond.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,6 @@
from aiogram import Bot, Dispatcher
from aiogram.fsm.storage.memory import MemoryStorage

# def signal_handler(sig, frame):
# raise RuntimeError('Interrupted Ctrl+C')

# signal.signal(signal.SIGINT, signal_handler)


bot = Bot(token=os.environ['JBOND_BOT_TOKEN'])
with open("/opt/jbond/token", 'r') as token:
bot = Bot(token=token.readline().strip())
dispatcher = Dispatcher(storage=MemoryStorage())


# async def main():
# await dispatcher.start_polling(bot)

# def main():
# timer = TimeThread()
# timer.start()

# jbond = JBond()
# jbond.start()

# while (True):
# sleep(1)

# if __name__ == '__main__':
# main()
6 changes: 0 additions & 6 deletions src/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,3 @@
LOG_FORMAT = '%(asctime)s(%(threadName)s) %(levelname)s - %(message)s'

logging.basicConfig(filename='/opt/jbond/jbond.log', level=logging.INFO)

# logger = logging.getLogger(__name__)

# handler = logging.StreamHandler(sys.stdout)
# handler.setFormatter(logging.Formatter(fmt=LOG_FORMAT))
# logging.getLogger().addHandler(handler)
4 changes: 4 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import os
import asyncio
from jbond import bot, dispatcher #,scheduler
from handlers.start import start_router
from logger import *

logger = logging.getLogger("Main")


async def main():
Expand Down
24 changes: 0 additions & 24 deletions src/time_source.py

This file was deleted.