Skip to content

Commit 19b8952

Browse files
Merge pull request #10 from CoolCoderCarl/develop
Develop
2 parents 775b9f2 + 177e014 commit 19b8952

21 files changed

Lines changed: 490 additions & 175 deletions

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Git
2+
.git
3+
.github
4+
.gitignore
5+
.gitattributes
6+
7+
# Docker
8+
docker-compose.yml
9+
**/Dockerfile
10+
**/Containerfile*
11+
.docker
12+
.dockerignore
13+
14+
# Meta
15+
README.md
16+
LICENSE
17+
requirements.txt

.github/workflows/code_quality.yaml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,3 @@ jobs:
3636
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
3737
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
3838
39-
pytesting:
40-
runs-on: ubuntu-latest
41-
name: Testing with pytest
42-
container: python:3.9
43-
needs: [ code_quality ]
44-
45-
steps:
46-
47-
- name: Checkout code
48-
uses: actions/checkout@v2
49-
50-
- name: Run script
51-
run: pip install -r requirements.txt
52-
53-
- name: Testing
54-
run: pytest -v ./tests/
55-
56-
- name: Notify if failure
57-
if: ${{ failure() }}
58-
uses: appleboy/telegram-action@master
59-
with:
60-
to: ${{ secrets.TELEGRAM_CHAT }}
61-
token: ${{ secrets.TELEGRAM_TOKEN }}
62-
format: html
63-
message: |
64-
<b>!!! FAILED !!!</b>
65-
<b>Failed job:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
66-
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -60,41 +60,35 @@ jobs:
6060
strategy:
6161
matrix:
6262
include:
63-
- os: windows-latest
64-
TARGET: windows
65-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
66-
OUT_FILE_NAME: truth_seeker.exe
67-
ASSET_MIME: application/vnd.microsoft.portable-executable
6863
- os: ubuntu-latest
69-
TARGET: ubuntu
70-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
71-
OUT_FILE_NAME: truth_seeker
72-
ASSET_MIME: application/x-binary
64+
SERVICENAME: news_db
65+
CONTAINERFILE: Containerfile-db
66+
- os: ubuntu-latest
67+
SERVICENAME: truth_seeker
68+
CONTAINERFILE: Containerfile-ts
69+
- os: ubuntu-latest
70+
SERVICENAME: datapath
71+
CONTAINERFILE: Containerfile-dp
7372

7473
steps:
7574

76-
- name: Checkout code
77-
uses: actions/checkout@v2
78-
79-
- name: Set up Python 3.9
80-
uses: actions/setup-python@v2
75+
- name: Login to DockerHub
76+
uses: docker/login-action@v1
8177
with:
82-
python-version: 3.9
78+
username: ${{ secrets.DOCKER_USERNAME }}
79+
password: ${{ secrets.DOCKER_TOKEN }}
8380

84-
- name: Install dependencies
85-
run: |
86-
python -m pip install --upgrade pip
87-
pip install -r requirements.txt
88-
89-
- name: Build with pyinstaller for ${{ matrix.TARGET }}
90-
run: ${{ matrix.CMD_BUILD }}
81+
- name: Checkout code
82+
uses: actions/checkout@v2
9183

92-
- name: Upload Artifacts
93-
uses: actions/upload-artifact@v3
84+
- name: Build and push
85+
id: push_image
86+
uses: docker/build-push-action@v2
9487
with:
95-
name: ${{ matrix.OUT_FILE_NAME }}
96-
path: ./dist/${{ matrix.OUT_FILE_NAME }}
97-
retention-days: 1
88+
context: .
89+
push: true
90+
file: ${{ matrix.CONTAINERFILE }}
91+
tags: h0d0user/${{ matrix.SERVICENAME }}:${{ needs.prepare.outputs.get_current_tag }}
9892

9993
- name: Notify if failure
10094
if: ${{ failure() }}
@@ -132,6 +126,9 @@ jobs:
132126
133127
Branch: ${{ github.ref }}
134128
135-
<b>Artifacts:</b> https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
129+
<b>Pushed image:</b> <code>docker pull h0d0user/news_db:${{ needs.prepare.outputs.get_current_tag }}</code>,
130+
<code>docker pull h0d0user/truth_seeker:${{ needs.prepare.outputs.get_current_tag }}</code>,
131+
<code>docker pull h0d0user/datapath:${{ needs.prepare.outputs.get_current_tag }}</code>
132+
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
136133
137134
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}

.github/workflows/release.yaml

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -103,52 +103,35 @@ jobs:
103103
strategy:
104104
matrix:
105105
include:
106-
- os: windows-latest
107-
TARGET: windows
108-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
109-
OUT_FILE_NAME: truth_seeker.exe
110-
ASSET_MIME: application/vnd.microsoft.portable-executable
111106
- os: ubuntu-latest
112-
TARGET: ubuntu
113-
CMD_BUILD: python -m PyInstaller --clean --workpath /tmp/build --specpath /tmp -F ./app/truth_seeker.py
114-
OUT_FILE_NAME: truth_seeker
115-
ASSET_MIME: application/x-binary
107+
SERVICENAME: news_db
108+
CONTAINERFILE: Containerfile-db
109+
- os: ubuntu-latest
110+
SERVICENAME: truth_seeker
111+
CONTAINERFILE: Containerfile-ts
112+
- os: ubuntu-latest
113+
SERVICENAME: datapath
114+
CONTAINERFILE: Containerfile-dp
116115

117116
steps:
118117

119-
- name: Checkout code
120-
uses: actions/checkout@v2
121-
122-
- name: Set up Python 3.9
123-
uses: actions/setup-python@v2
118+
- name: Login to DockerHub
119+
uses: docker/login-action@v1
124120
with:
125-
python-version: 3.9
126-
127-
- name: Install dependencies
128-
run: |
129-
python -m pip install --upgrade pip
130-
pip install -r requirements.txt
131-
132-
- name: Build with pyinstaller for ${{ matrix.TARGET }}
133-
run: ${{ matrix.CMD_BUILD }}
121+
username: ${{ secrets.DOCKER_USERNAME }}
122+
password: ${{ secrets.DOCKER_TOKEN }}
134123

135-
- name: Upload Artifacts
136-
uses: actions/upload-artifact@v3
137-
with:
138-
name: ${{ matrix.OUT_FILE_NAME }}
139-
path: ./dist/${{ matrix.OUT_FILE_NAME }}
140-
retention-days: 1
124+
- name: Checkout code
125+
uses: actions/checkout@v2
141126

142-
- name: Upload Release Asset
143-
id: upload-release-asset
144-
uses: actions/upload-release-asset@v1
145-
env:
146-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
- name: Build and push
128+
id: push_image
129+
uses: docker/build-push-action@v2
147130
with:
148-
upload_url: ${{ needs.release.outputs.get_release_url }}
149-
asset_path: ./dist/${{ matrix.OUT_FILE_NAME }}
150-
asset_name: ${{ matrix.OUT_FILE_NAME }}
151-
asset_content_type: ${{ matrix.ASSET_MIME }}
131+
context: .
132+
push: true
133+
file: ${{ matrix.CONTAINERFILE }}
134+
tags: h0d0user/${{ matrix.SERVICENAME }}:latest
152135

153136
- name: Notify if failure
154137
if: ${{ failure() }}
@@ -186,6 +169,11 @@ jobs:
186169
187170
Branch: ${{ github.ref }}
188171
172+
<b>Pushed image:</b> <code>docker pull h0d0user/news_db:latest</code>,
173+
<code>docker pull h0d0user/truth_seeker:latest</code>,
174+
<code>docker pull h0d0user/datapath:latest</code>
175+
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
176+
189177
<b>Release URL:</b> https://github.com/${{ github.repository }}/releases/tag/${{ needs.prepare.outputs.get_current_tag }}
190178
191179
See changes: https://github.com/${{ github.repository }}/commit/${{ github.sha }}

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,7 @@ dmypy.json
129129
.pyre/
130130

131131
# Secret file
132-
.secrets.toml
132+
settings.toml
133+
134+
# Database files
135+
*.db

Containerfile-db

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.9-alpine as builder
2+
3+
COPY ["truth_seeker.py", "/opt/"]
4+
COPY ["datapath.py", "/opt/"]
5+
COPY ["news_db.py", "/opt/"]
6+
COPY ["dynaconfig.py", "/opt/"]
7+
COPY requirements-db.txt requirements-db.txt
8+
9+
RUN pip3 install --no-cache-dir -r requirements-db.txt
10+
11+
FROM builder
12+
13+
CMD ["python3.9", "/opt/news_db.py"]

Containerfile-dp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.9-alpine as builder
2+
3+
COPY ["truth_seeker.py", "/opt/"]
4+
COPY ["datapath.py", "/opt/"]
5+
COPY ["news_db.py", "/opt/"]
6+
COPY ["dynaconfig.py", "/opt/"]
7+
COPY requirements-dp.txt requirements-dp.txt
8+
9+
RUN pip3 install --no-cache-dir -r requirements-dp.txt
10+
11+
FROM builder
12+
13+
CMD ["python3.9", "/opt/datapath.py"]

Containerfile-ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.9-alpine as builder
2+
3+
COPY ["truth_seeker.py", "/opt/"]
4+
COPY ["datapath.py", "/opt/"]
5+
COPY ["news_db.py", "/opt/"]
6+
COPY ["dynaconfig.py", "/opt/"]
7+
COPY requirements-ts.txt requirements-ts.txt
8+
9+
RUN pip3 install --no-cache-dir -r requirements-ts.txt
10+
11+
FROM builder
12+
13+
CMD ["python3.9", "/opt/truth_seeker.py"]

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
# truth_seeker
1+
# truth_seeker
2+
3+
Simple ETL getting info from https://newsapi.org/ and send to telegram channel
4+
5+
## Prehistory
6+
This simple service help to search information automatically via News API
7+
8+
> Datapath it is like telepath or astropath
9+
> (c) Author
10+
11+
Enjoy.
12+
13+
## How to use
14+
You can check the last available tags here -
15+
1) https://hub.docker.com/repository/docker/h0d0user/truth_seeker
16+
2) https://hub.docker.com/repository/docker/h0d0user/datapath
17+
3) https://hub.docker.com/repository/docker/h0d0user/news_db
18+
19+
Need to fill `settings.toml` with next important variables:
20+
1) `API_KEY`. You can find this data here - https://my.telegram.org/apps
21+
2) `API_TOKEN`. Ask *BotFather* in telegram.
22+
3) `CHAT_ID`. Use this to find chat ID where you want to send messages - https://api.telegram.org/bot<API_TOKEN>/getUpdates
23+
4) `DB_NAME`. Where you want to load your data before send to telegram.
24+
5) `QUERY`. Key word to search for in articles.
25+
6) `docker-compose up -d`
26+
7) ...
27+
8) PROFIT !!!
28+
29+
**Still have questions ? Google it.**

app/truth_seeker.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)