1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
name: Notify documentation review assignees on new commits
on:
pull_request_target:
# 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]
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')
permissions:
issues: write
pull-requests: read
runs-on: [self-hosted, auto-provisioned, build-preset-analytic-node]
env:
GITHUB_TOKEN: ${{ secrets.YDBOT_TOKEN }}
steps:
- uses: actions/github-script@v8
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 a look.`
});
|