Skip to content

Commit ce995a1

Browse files
committed
ci: replace agentscan action with the github app
1 parent 666ef53 commit ce995a1

2 files changed

Lines changed: 67 additions & 97 deletions

File tree

‎.github/agentscan.yml‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# yaml-language-server: $schema=https://agentscan.tools/schemas/agentscan.json
2+
version: 1
3+
4+
mode: full
5+
6+
auto-close: true
7+
auto-close-classifications:
8+
- automation
9+
10+
trusted-author-associations:
11+
- owner
12+
- member
13+
- collaborator
14+
- contributor
15+
16+
labels:
17+
automation: possible bot
18+
mixed: possible bot
19+
community-flagged: possible bot
20+
21+
messages:
22+
automation: |
23+
We've flagged this as a potential contribution without a human behind it. We welcome the thoughtful use of AI tools when contributing, but ask all contributors to follow [two core principles](https://roe.dev/blog/using-ai-in-open-source):
24+
25+
1. **Never let an LLM speak for you** - all comments, issues, and PR descriptions should be written in your own words, reflecting your own understanding.
26+
2. **Never let an LLM think for you** - only submit contributions you fully understand and can explain.
27+
28+
Please review these AI-assisted contribution guidelines and update this contribution if needed.
29+
30+
We're closing this for now as the account looks automated. If we got that wrong, please just reopen the PR and we'll take another look.
31+
mixed: |
32+
We've flagged this as a potential contribution without a human behind it. We welcome the thoughtful use of AI tools when contributing, but ask all contributors to follow [two core principles](https://roe.dev/blog/using-ai-in-open-source):
33+
34+
1. **Never let an LLM speak for you** - all comments, issues, and PR descriptions should be written in your own words, reflecting your own understanding.
35+
2. **Never let an LLM think for you** - only submit contributions you fully understand and can explain.
36+
37+
Please review these AI-assisted contribution guidelines and update this contribution if needed.
38+
39+
If this was flagged in error, we apologise! 😳 Just let us know. 🙏
40+
community-flagged: |
41+
We've flagged this as a potential contribution without a human behind it. We welcome the thoughtful use of AI tools when contributing, but ask all contributors to follow [two core principles](https://roe.dev/blog/using-ai-in-open-source):
42+
43+
1. **Never let an LLM speak for you** - all comments, issues, and PR descriptions should be written in your own words, reflecting your own understanding.
44+
2. **Never let an LLM think for you** - only submit contributions you fully understand and can explain.
45+
46+
Please review these AI-assisted contribution guidelines and update this contribution if needed.
47+
48+
If this was flagged in error, we apologise! 😳 Just let us know. 🙏
49+
insufficient-data: |
50+
Looks like you're new to GitHub - we're delighted you'd like to contribute! 💚
51+
52+
We welcome the thoughtful use of AI tools when contributing, but ask all contributors to follow [two core principles](https://roe.dev/blog/using-ai-in-open-source):
53+
54+
1. **Never let an LLM speak for you** - all comments, issues, and PR descriptions should be written in your own words, reflecting your own understanding.
55+
2. **Never let an LLM think for you** - only submit contributions you fully understand and can explain.

‎.github/workflows/agent-scan.yml‎

Lines changed: 12 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,29 @@
11
name: agent-scan
22

33
on:
4-
# zizmor: ignore[dangerous-triggers] - DO NOT add action/checkout in this workflow as it uses pull_request_target
54
pull_request_target:
65
types:
7-
- opened
8-
- reopened
9-
10-
concurrency:
11-
group: agent-scan-${{ github.event.pull_request.number }}
12-
cancel-in-progress: true
6+
- closed
7+
- labeled
138

149
permissions:
15-
issues: write
1610
pull-requests: write
1711

1812
jobs:
19-
agentscan:
13+
rename:
14+
if: >-
15+
github.event.pull_request.state == 'closed'
16+
&& !github.event.pull_request.merged
17+
&& contains(github.event.pull_request.labels.*.name, 'possible bot')
18+
&& (github.event.action == 'closed' || github.event.label.name == 'possible bot')
2019
runs-on: ubuntu-latest
2120
steps:
22-
- name: AgentScan
23-
id: agentscan
24-
uses: MatteoGabriele/agentscan-action@8112fb79b33fafb8506159df20129a34209ac410 # v2.5.0
25-
with:
26-
github-token: ${{ secrets.GITHUB_TOKEN }}
27-
mode: silent
28-
- name: Handle flagged PR
29-
if: contains(fromJSON('["automation","mixed"]'), steps.agentscan.outputs.classification) || steps.agentscan.outputs.community-flagged == 'true'
30-
env:
31-
CLASSIFICATION: ${{ steps.agentscan.outputs.classification }}
32-
COMMUNITY_FLAGGED: ${{ steps.agentscan.outputs.community-flagged }}
33-
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
21+
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
3422
with:
3523
script: |
36-
const prNumber = context.payload.pull_request.number;
37-
const classification = process.env.CLASSIFICATION;
38-
const communityFlagged = process.env.COMMUNITY_FLAGGED === 'true';
39-
const shouldClose = classification === 'automation' || communityFlagged;
40-
41-
const issue = context.payload.pull_request
42-
const labels = issue.labels?.map(l => l.name) || []
43-
44-
if (!labels.includes('possible bot')) {
45-
await github.rest.issues.addLabels({
46-
owner: context.repo.owner,
47-
repo: context.repo.repo,
48-
issue_number: prNumber,
49-
labels: ['possible bot'],
50-
})
51-
}
52-
53-
const comments = await github.paginate(github.rest.issues.listComments, {
24+
await github.rest.pulls.update({
5425
owner: context.repo.owner,
5526
repo: context.repo.repo,
56-
issue_number: prNumber,
57-
per_page: 100,
27+
pull_number: context.payload.pull_request.number,
28+
title: '🚨 unwelcome pr from bot 🚨',
5829
})
59-
60-
const alreadyCommented = comments.some(
61-
c => c.user.type === 'Bot' && c.body.includes('AI-assisted contribution guidelines')
62-
)
63-
64-
if (!alreadyCommented) {
65-
const closingNote = shouldClose
66-
? "We're closing this for now as the account looks automated. If we got that wrong, please just reopen the PR and we'll take another look."
67-
: 'If this was flagged in error, we apologise! 😳 Just let us know. 🙏'
68-
69-
await github.rest.issues.createComment({
70-
owner: context.repo.owner,
71-
repo: context.repo.repo,
72-
issue_number: prNumber,
73-
body: [
74-
"We've flagged this as a potential contribution without a human behind it. We welcome the thoughtful use of AI tools when contributing, but ask all contributors to follow [two core principles](https://roe.dev/blog/using-ai-in-open-source):",
75-
'',
76-
'1. **Never let an LLM speak for you** - all comments, issues, and PR descriptions should be written in your own words, reflecting your own understanding.',
77-
'2. **Never let an LLM think for you** - only submit contributions you fully understand and can explain.',
78-
'',
79-
'Please review these AI-assisted contribution guidelines and update this contribution if needed.',
80-
'',
81-
closingNote,
82-
].join('\n'),
83-
})
84-
} else {
85-
core.info('Possible-bot comment already exists - skipping comment.')
86-
}
87-
88-
if (shouldClose && issue.state === 'open' && !alreadyCommented) {
89-
await github.rest.pulls.update({
90-
owner: context.repo.owner,
91-
repo: context.repo.repo,
92-
pull_number: prNumber,
93-
state: 'closed',
94-
title: '🚨 unwelcome pr from bot 🚨',
95-
})
96-
}
97-
98-
const actionTaken = [
99-
'Added `possible bot` label',
100-
alreadyCommented ? null : 'posted policy comment',
101-
shouldClose && !alreadyCommented ? 'closed PR' : null,
102-
].filter(Boolean).join(', ')
103-
104-
core.summary
105-
.addHeading('AgentScan: Possible Bot Flag', 2)
106-
.addTable([
107-
[{ data: 'Property', header: true }, { data: 'Value', header: true }],
108-
['Pull Request', `#${prNumber}`],
109-
['Classification', classification],
110-
['Community flagged', String(communityFlagged)],
111-
['Action', actionTaken || 'No action (already handled)'],
112-
])
113-
114-
await core.summary.write()

0 commit comments

Comments
 (0)