Skip to content

Commit 7665f79

Browse files
committed
fix
1 parent e493353 commit 7665f79

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.github/workflows/deploy-ycf.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ on:
33
push:
44
paths:
55
- 'src/**'
6+
- 'main.py'
67
- 'requirements.txt'
78
- 'terraform/metadata.yml'
89
- '.github/workflows/deploy-ycf.yml'
910

1011

11-
# https://github.com/yc-actions/yc-iam-token-fed
12-
1312
jobs:
1413
deploy:
1514
runs-on: ubuntu-latest
@@ -26,11 +25,13 @@ jobs:
2625
memory: '256Mb'
2726
execution-timeout: '180'
2827
service-account: ${{ secrets.YC_SA_ID }}
29-
entrypoint: 'src/main.telegram_webhook'
28+
entrypoint: 'main.telegram_webhook'
3029
environment: |
3130
TELEGRAM_BOT_TOKEN=${{ secrets.TELEGRAM_BOT_TOKEN }}
3231
YC_FOLDER_ID=${{ vars.YC_FOLDER_ID }}
3332
TELEGRAM_CHAT_WHITELIST=${{ vars.TELEGRAM_CHAT_WHITELIST }}
3433
include: |
35-
./src
34+
main.py
3635
requirements.txt
36+
./src
37+
./terraform/metadata.yml

src/main.py renamed to main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
_app_initialized: bool = False
1818
_loop: Optional[asyncio.AbstractEventLoop] = None
1919

20+
METADATA_FILE = Path("./terraform/metadata.yml")
21+
2022

2123
def _get_loop() -> asyncio.AbstractEventLoop:
2224
global _loop
@@ -34,7 +36,7 @@ def _get_application():
3436
_application = build_app(
3537
tg_token=os.getenv("TELEGRAM_BOT_TOKEN"),
3638
folder_id=os.getenv("YC_FOLDER_ID"),
37-
script=Path("../terraform/metadata.yml").absolute(),
39+
script=METADATA_FILE.absolute(),
3840
chat_whitelist=get_whitelist()
3941
)
4042

@@ -86,7 +88,7 @@ def telegram_webhook(event: dict, context: dict):
8688
tg_token=os.getenv("TELEGRAM_BOT_TOKEN"),
8789
yc_token=os.getenv("YC_OAUTH_TOKEN"),
8890
folder_id=os.getenv("YC_FOLDER_ID"),
89-
script=Path("../terraform/metadata.yml"),
91+
script=METADATA_FILE,
9092
chat_whitelist=get_whitelist()
9193
)
9294

src/tg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ async def stop_proxy(update: Update, context: ContextTypes.DEFAULT_TYPE):
5858
def build_app(tg_token: str, folder_id: str, script: Path, chat_whitelist: list[int], yc_token: str = None) -> Application:
5959
if tg_token is None or yc_token is None or script is None:
6060
raise ValueError("Telegram token, Folder ID and script must be provided")
61+
if not script.exists():
62+
raise ValueError("Script file does not exist")
6163

6264
application = ApplicationBuilder().token(tg_token).build()
6365

0 commit comments

Comments
 (0)