Skip to content

Commit

Permalink
ci: add github-watcher action (#22)
Browse files Browse the repository at this point in the history
* fix: change release job id

* fix: github clients logging

* ci: add github-watcher action
  • Loading branch information
ovsds authored Apr 10, 2024
1 parent a4c95fd commit 0952f2f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/github-watcher-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
tasks:
- id: self
triggers:
- id: github
type: github
token_secret:
type: env
key: GITHUB_TOKEN
owner: ovsds
repos:
- github-watcher
subtriggers:
- type: repository_issue_created
exclude_author:
- ovsds
- type: repository_pr_created
exclude_author:
- ovsds
- type: repository_failed_workflow_run
exclude:
- Check PR
actions:
- id: telegram_webhook
type: telegram_webhook
chat_id_secret:
type: env
key: TELEGRAM_CHAT_ID
token_secret:
type: env
key: TELEGRAM_TOKEN
29 changes: 29 additions & 0 deletions .github/workflows/github-watcher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Github Watcher

concurrency:
group: ${{ github.workflow }}

on:
schedule:
- cron: "*/5 * * * *" # every 5 minutes
workflow_dispatch:

jobs:
run-github-watcher:
runs-on: ubuntu-20.04

permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run
uses: ovsds/github-watcher-action@main
with:
config_path: .github/github-watcher-config.yaml
env_variables: |
GITHUB_TOKEN=${{ secrets.PERSONAL_GITHUB_TOKEN }}
TELEGRAM_TOKEN=${{ secrets.TELEGRAM_TOKEN }}
TELEGRAM_CHAT_ID=${{ secrets.TELEGRAM_CHAT_ID }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- published

jobs:
deploy:
release:
runs-on: ubuntu-20.04

permissions:
Expand Down
4 changes: 4 additions & 0 deletions backend/lib/github/clients/gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import contextlib
import dataclasses
import datetime
import logging
import typing

import gql
Expand All @@ -12,6 +13,8 @@

import lib.github.models as github_models

logger = logging.getLogger(__name__)


class BaseRequest(abc.ABC):
document: graphql.DocumentNode = NotImplemented
Expand Down Expand Up @@ -199,6 +202,7 @@ async def gql_client(self) -> typing.AsyncGenerator[gql.Client, None]:
await gql_transport.close()

async def _request(self, request: BaseRequest, response_model: type[ResponseT]) -> ResponseT:
logger.debug("Requesting document(%s) params(%s)", request.document, request.params)
async with self.gql_client() as gql_client:
response = await gql_client.execute_async(
document=request.document,
Expand Down
2 changes: 1 addition & 1 deletion backend/lib/github/clients/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def _request(
"Authorization": f"Bearer {self._token}",
"Accept": "application/vnd.github.v3+json",
}
logger.info("Requesting method(%s) url(%s) params(%s)", request.method, request.url, request.params)
logger.debug("Requesting method(%s) url(%s) params(%s)", request.method, request.url, request.params)
async with self._aiohttp_client.request(
method=request.method,
url=request.url,
Expand Down

0 comments on commit 0952f2f

Please sign in to comment.