Skip to content

Commit c99abba

Browse files
committed
ci: add /verify PR-comment command (relays to TechEngine)
Members can type /verify (or @TechEngineBot verify) on a PR to trigger on-demand Tier 0 verification; relays to TechEngine which posts the band report as the bot. Refs #1
1 parent 222ae80 commit c99abba

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: verify-command
2+
3+
# Type `/verify` (or `@TechEngineBot verify`) in a TechAPI PR comment to trigger an
4+
# on-demand Tier 0 data verification. issue_comment fires in this repo, so the
5+
# listener lives here; it relays the request to TechEngine (which holds the bot
6+
# token + runs app.verify) via repository_dispatch. TechEngine posts the band
7+
# report back on the PR as TechEngineBot. Restricted to repo members/collaborators.
8+
on:
9+
issue_comment:
10+
types: [created]
11+
12+
permissions:
13+
contents: read
14+
pull-requests: read
15+
issues: write # react to the command comment as acknowledgement
16+
17+
jobs:
18+
relay:
19+
runs-on: ubuntu-latest
20+
# Only on PR comments, only for the command, only from trusted authors.
21+
if: >-
22+
github.event.issue.pull_request &&
23+
(startsWith(github.event.comment.body, '/verify') ||
24+
contains(github.event.comment.body, '@TechEngineBot verify')) &&
25+
contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association)
26+
env:
27+
ENGINE_TOKEN: ${{ secrets.ENGINE_TOKEN }}
28+
steps:
29+
- name: Dormant when ENGINE_TOKEN is unset
30+
if: env.ENGINE_TOKEN == ''
31+
run: echo "::warning::ENGINE_TOKEN not configured; cannot relay /verify to TechEngine."
32+
33+
- name: Acknowledge + relay to TechEngine
34+
if: env.ENGINE_TOKEN != ''
35+
uses: actions/github-script@v7
36+
with:
37+
github-token: ${{ secrets.ENGINE_TOKEN }}
38+
script: |
39+
const { owner, repo } = context.repo;
40+
const issue_number = context.issue.number;
41+
// 👀 reaction so the requester sees the command was picked up.
42+
try {
43+
await github.rest.reactions.createForIssueComment({
44+
owner, repo, comment_id: context.payload.comment.id, content: 'eyes',
45+
});
46+
} catch (e) {
47+
core.info(`reaction skipped: ${e.message}`);
48+
}
49+
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
50+
await github.rest.repos.createDispatchEvent({
51+
owner: 'GetTechAPI',
52+
repo: 'TechEngine',
53+
event_type: 'techapi-verify',
54+
client_payload: {
55+
pr_number: String(issue_number),
56+
head_sha: pr.data.head.sha,
57+
requested_by: context.payload.comment.user.login,
58+
},
59+
});
60+
core.info(`relayed /verify for PR #${issue_number} @ ${pr.data.head.sha}`);

0 commit comments

Comments
 (0)