diff options
author | Ivan Blinkov <ivan@ydb.tech> | 2025-04-20 22:21:16 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-20 15:21:16 +0000 |
commit | 15b9993663ebf9b6522395f3470e1cb4f2958934 (patch) | |
tree | 21cd61ca13d4eee147103642f6c5554ea6c3484d | |
parent | d02bceec59d9a4ed6e19c62f45027f29970dfc8c (diff) | |
download | ydb-main.tar.gz |
-rw-r--r-- | .github/workflows/docs_notify_assignees.yaml | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/.github/workflows/docs_notify_assignees.yaml b/.github/workflows/docs_notify_assignees.yaml new file mode 100644 index 0000000000..07be79dfc9 --- /dev/null +++ b/.github/workflows/docs_notify_assignees.yaml @@ -0,0 +1,56 @@ +name: Notify documentation review assignees on new commits + +on: + pull_request: + # Fires on new commits and on label changes, so the job + # starts as soon as the label is added, then on every push. + types: [synchronize, labeled] + +permissions: + issues: write + pull-requests: read + +concurrency: + group: pr-${{ github.event.pull_request.number }}-doc-notify + cancel-in-progress: true + +jobs: + ping: + if: contains(github.event.pull_request.labels.*.name, 'documentation') + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + github-token: ${{ secrets.YDBOT_TOKEN }} + script: | + const pr = context.payload.pull_request; + const assignees = pr.assignees.map(a => `@${a.login}`).join(' '); + if (!assignees) { + core.info('No assignees, nothing to ping.'); + return; + } + + // Check when the bot (this token) last commented + const { data: me } = await github.rest.users.getAuthenticated(); + const { data: comments } = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + per_page: 1, + sort: 'created', + direction: 'desc' + }); + const myLast = comments.find(c => c.user.login === me.login); + + // Skip if commented recently enough + if (myLast && Date.now() - new Date(myLast.created_at) < 15 * 60 * 1000) { + core.info('Skip: already commented within 15 minutes.'); + return; + } + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + body: `🔄 New commits pushed — ${assignees} please take another look.` + }); |