Skip to content

Commit 6c18061

Browse files
committed
wip
1 parent df0954b commit 6c18061

3 files changed

Lines changed: 9 additions & 29 deletions

File tree

.github/workflows/google-cloudrun-docker.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ jobs:
5959
with:
6060
credentials_json: ${{ secrets.GCP_SA_KEY }}
6161

62-
6362
- name: Set up Cloud SDK
6463
uses: 'google-github-actions/setup-gcloud@v2'
6564

6665
- name: Define image tag for deployment
6766
id: image_tag
6867
run: echo "TAG=${{ env.PROJECT_REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.ARTIFACT_REGISTRY }}/${{ env.SERVICE_NAME }}:${{ github.sha }}" >> $GITHUB_ENV
6968

69+
- name: Get existing service URL
70+
id: get_url
71+
run: echo "URL=$(gcloud run services describe ${{ env.SERVICE_NAME }} --platform managed --region ${{ env.PROJECT_REGION }} --format 'value(status.url)')" >> $GITHUB_ENV
72+
7073
- name: Deploy to Cloud Run
7174
run: |-
7275
gcloud run deploy ${{ env.SERVICE_NAME }} \
@@ -83,15 +86,6 @@ jobs:
8386
--set-secrets=S3_ACCESS_SECRET=${{ vars.GCP_SECRET_S3_ACCESS_SECRET }}:latest \
8487
--set-secrets=S3_HOST=${{ vars.GCP_SECRET_S3_HOST }}:latest \
8588
--set-env-vars=S3_BUCKET=${{ vars.GCP_S3_BUCKET }} \
89+
--update-env-vars=WEBHOOK_URL=${{ env.URL }} \
8690
--platform managed \
8791
--allow-unauthenticated
88-
89-
- name: Get service URL
90-
id: service_url
91-
run: echo "URL=$(gcloud run services describe ${{ env.SERVICE_NAME }} --platform managed --region ${{ env.PROJECT_REGION }} --format 'value(status.url)')" >> $GITHUB_ENV
92-
93-
- name: Set webhook URL environment variable
94-
run: |-
95-
gcloud run services update ${{ env.SERVICE_NAME }} \
96-
--region ${{ env.PROJECT_REGION }} \
97-
--update-env-vars=WEBHOOK_URL=${{ env.URL }}

main.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,15 @@ def main():
1616
# Initialize the database
1717
init_db()
1818

19-
# Get webhook URL from environment.
20-
webhook_url_from_env = os.environ.get("WEBHOOK_URL")
19+
# The WEBHOOK_URL is now guaranteed to be set by the CI/CD pipeline.
20+
webhook_url = os.environ["WEBHOOK_URL"]
2121

22-
# Prepare the webhook_url parameter. It must be None if the env var is missing or empty.
23-
webhook_url_param = None
24-
if webhook_url_from_env: # This is only true if the string is not None and not empty.
25-
webhook_url_param = f'{webhook_url_from_env}/{os.environ["TELEGRAM_BOT_TOKEN"]}'
26-
2722
# Start the Bot
28-
# If webhook_url_param is None, run_webhook will only start the webserver without setting a webhook.
2923
application.run_webhook(
3024
listen="0.0.0.0",
3125
port=int(os.environ.get("PORT", 8080)),
32-
#url_path=os.environ["TELEGRAM_BOT_TOKEN"],
33-
#webhook_url=webhook_url_param,
26+
url_path=os.environ["TELEGRAM_BOT_TOKEN"],
27+
webhook_url=f'{webhook_url.rstrip("/")}/{os.environ["TELEGRAM_BOT_TOKEN"]}',
3428
)
3529

3630
if __name__ == "__main__":

utils/hora_feliz_dia.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66

77
import pytz
88

9-
10-
def get_hora_feliz_dia():
11-
tz = pytz.timezone("America/Argentina/Buenos_Aires")
12-
now = datetime.datetime.now(tz).date()
13-
midnight = tz.localize(datetime.datetime.combine(now, datetime.time(0, 0, 3)), is_dst=None)
14-
return midnight.astimezone(pytz.utc).time()
15-
16-
179
def get_hora_update_groups():
1810
tz = pytz.timezone("America/Argentina/Buenos_Aires")
1911
now = datetime.datetime.now(tz).date()

0 commit comments

Comments
 (0)