mirror of
https://github.com/serega404/VodokanalBot.git
synced 2025-04-21 22:40:46 +03:00
Compare commits
3 Commits
2a968f3528
...
80af7ec775
Author | SHA1 | Date | |
---|---|---|---|
80af7ec775 | |||
6d65395b89 | |||
5388901294 |
41
.github/workflows/github-push-docker.yml
vendored
Normal file
41
.github/workflows/github-push-docker.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
name: Create and publish a Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['main']
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-image:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
FROM python:3.11.2-alpine3.17
|
||||||
|
|
||||||
|
LABEL Maintainer="serega404"
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY requirements.txt requirements.txt
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
# Setting up crontab
|
||||||
|
COPY crontab /tmp/crontab
|
||||||
|
RUN cat /tmp/crontab > /etc/crontabs/root
|
||||||
|
|
||||||
|
COPY main.py main.py
|
||||||
|
|
||||||
|
# run crond as main process of container
|
||||||
|
CMD ["crond", "-f", "-l", "2"]
|
24
README.md
24
README.md
@ -1 +1,25 @@
|
|||||||
# VodokanalParser
|
# VodokanalParser
|
||||||
|
|
||||||
|
[](https://github.com/serega404/VodokanalBot)
|
||||||
|
|
||||||
|
### Запуск в Docker
|
||||||
|
|
||||||
|
``` Docker
|
||||||
|
docker volume create vodokanal_bot_data
|
||||||
|
docker run -d --name VodokanalBot \
|
||||||
|
--restart=always \
|
||||||
|
-v vodokanal_bot_data:/app/data \
|
||||||
|
-e TZ='Europe/Moscow' \
|
||||||
|
-e TELEGRAM_TOKEN='TOKEN' \
|
||||||
|
-e TELEGRAM_CHANNEL='CHAT_ID' \
|
||||||
|
ghcr.io/serega404/vodokanalbot:main
|
||||||
|
```
|
||||||
|
|
||||||
|
### Библиотеки
|
||||||
|
|
||||||
|
* [Requests](https://requests.readthedocs.io/en/latest/)
|
||||||
|
* [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/)
|
||||||
|
|
||||||
|
### Лицензия
|
||||||
|
|
||||||
|
Распространяется под MIT License. Смотри файл [`LICENSE`](./LICENSE) для того что бы узнать подробности.
|
||||||
|
2
crontab
Normal file
2
crontab
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@reboot cd /app && python3 /app/main.py
|
||||||
|
*/10 * * * * cd /app && python3 /app/main.py
|
9
main.py
9
main.py
@ -20,8 +20,8 @@ if TELEGRAM_CHANNEL == '':
|
|||||||
# Load database
|
# Load database
|
||||||
|
|
||||||
db = None
|
db = None
|
||||||
if (os.path.isfile('db.json')):
|
if (os.path.isfile('data/db.json')):
|
||||||
with open('db.json', 'r', encoding='utf-8') as f:
|
with open('data/db.json', 'r', encoding='utf-8') as f:
|
||||||
db = json.load(f)
|
db = json.load(f)
|
||||||
else:
|
else:
|
||||||
print("Database not loaded")
|
print("Database not loaded")
|
||||||
@ -71,6 +71,9 @@ else:
|
|||||||
|
|
||||||
# Save database
|
# Save database
|
||||||
|
|
||||||
with open('db.json', 'w', encoding='utf-8') as f:
|
if not os.path.exists("data"):
|
||||||
|
os.makedirs("data")
|
||||||
|
|
||||||
|
with open('data/db.json', 'w', encoding='utf-8') as f:
|
||||||
json.dump(elements, f, ensure_ascii=False)
|
json.dump(elements, f, ensure_ascii=False)
|
||||||
print("Database updated")
|
print("Database updated")
|
||||||
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
requests
|
||||||
|
beautifulsoup4
|
Loading…
x
Reference in New Issue
Block a user