Skip to content

Commit 9e0cf38

Browse files
committed
VAMOAROMPERTODO
1 parent 4868a03 commit 9e0cf38

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ COPY . .
3030
ENV PYTHONPATH /app/packages
3131

3232

33+
ENTRYPOINT ["python"]
3334
CMD ["main.py"]

cloudbuild.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
steps:
2+
# Build the container image
3+
- name: 'gcr.io/cloud-builders/docker'
4+
args:
5+
- 'build'
6+
- '-t'
7+
- 'us-central1-docker.pkg.dev/$PROJECT_ID/dcubabot/dcubabot:latest'
8+
- '.'
9+
10+
# Push the container image to Artifact Registry
11+
- name: 'gcr.io/cloud-builders/docker'
12+
args:
13+
- 'push'
14+
- 'us-central1-docker.pkg.dev/$PROJECT_ID/dcubabot/dcubabot:latest'
15+
16+
# Deploy the main service to Cloud Run
17+
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
18+
entrypoint: gcloud
19+
args:
20+
- 'run'
21+
- 'deploy'
22+
- 'dcubabot'
23+
- '--image=us-central1-docker.pkg.dev/$PROJECT_ID/dcubabot/dcubabot:latest'
24+
- '--platform=managed'
25+
- '--region=us-central1'
26+
- '--allow-unauthenticated'
27+
- '--port=8080'
28+
29+
# Deploy the scheduled job for updating groups
30+
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
31+
entrypoint: gcloud
32+
args:
33+
- 'run'
34+
- 'jobs'
35+
- 'deploy'
36+
- 'dcubabot-update-groups'
37+
- '--image=us-central1-docker.pkg.dev/$PROJECT_ID/dcubabot/dcubabot:latest'
38+
- '--region=us-central1'
39+
- '--command=python'
40+
- '--args=cron.py'
41+
- '--schedule=0 0 * * *' # Daily at midnight
42+
- '--time-zone=America/Argentina/Buenos_Aires'

cron.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import asyncio
2+
import os
3+
import logging
4+
from telegram.ext import Application
5+
from bot_logic import _update_groups
6+
7+
def main():
8+
"""Runs the update_groups command."""
9+
logging.basicConfig(
10+
level=logging.INFO,
11+
format='[%(asctime)s] - [%(name)s] - [%(levelname)s] - %(message)s',
12+
)
13+
14+
application = Application.builder().token(os.environ["TELEGRAM_BOT_TOKEN"]).build()
15+
16+
async def run_update():
17+
await _update_groups(application)
18+
19+
asyncio.run(run_update())
20+
21+
if __name__ == "__main__":
22+
main()

0 commit comments

Comments
 (0)