1+ name : Audit Agent
2+
3+ on :
4+ pull_request :
5+
6+ jobs :
7+ quick-scan :
8+ runs-on : ubuntu-latest
9+ env :
10+ AUDIT_AGENT_TOKEN : ${{ secrets.AUDIT_AGENT_TOKEN }}
11+ steps :
12+ - uses : actions/checkout@v4
13+ with :
14+ fetch-depth : 2
15+
16+ - name : Extract commit message and files
17+ id : extract
18+ run : |
19+ # Get the commit message from the PR head
20+ COMMIT_MSG=$(git log -1 --format=%B ${{ github.event.pull_request.head.sha }})
21+
22+ echo "Commit message: $COMMIT_MSG"
23+
24+ # Check if commit message matches pattern "scan: [...]"
25+ if echo "$COMMIT_MSG" | grep -q '^scan: \[.*\]'; then
26+ echo "should_scan=true" >> $GITHUB_OUTPUT
27+ # Extract the file list (everything after "scan: ")
28+ FILES=$(echo "$COMMIT_MSG" | sed 's/^scan: //')
29+
30+ # Check if files are already quoted, if not add quotes
31+ if ! echo "$FILES" | grep -q '"'; then
32+ # No quotes found, add them around each file
33+ # Convert [file1,file2,file3] to ["file1","file2","file3"]
34+ FILES=$(echo "$FILES" | sed 's/\[/["/; s/\]/"]/' | sed 's/,/","/g' | sed 's/ //g')
35+ fi
36+
37+ echo "files=$FILES" >> $GITHUB_OUTPUT
38+ echo "Found scan request with files: $FILES"
39+ else
40+ echo "should_scan=false" >> $GITHUB_OUTPUT
41+ echo "No scan request found in commit message"
42+ fi
43+
44+ - name : Quick Scan
45+ if : steps.extract.outputs.should_scan == 'true'
46+ run : |
47+ curl -X POST \
48+ -H "Content-Type: application/json" \
49+ -H "X-Api-Key: $AUDIT_AGENT_TOKEN" \
50+ -d '{
51+ "githubUrl": "${{ github.event.repository.html_url }}",
52+ "branchName": "${{ github.event.pull_request.head.ref }}",
53+ "issueNumber": ${{ github.event.number }},
54+ "commitHash": "${{ github.event.pull_request.head.sha }}",
55+ "contractFiles": ${{ steps.extract.outputs.files }}
56+ }' \
57+ https://api.auditagent.nethermind.io/api/v1/scanner/quick-scan/launch
0 commit comments