File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : PR Reviewer Agent
2
+ on :
3
+ issue_comment :
4
+ types : [created]
5
+ pull_request :
6
+ types : [opened, synchronize, reopened]
7
+ push :
8
+ jobs :
9
+ process_pr_events :
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - name : Extract event details
13
+ run : echo "EVENT_PAYLOAD=$(jq -c . < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
14
+
15
+ - name : Generate Signature and Encrypt Token
16
+ env :
17
+ WEBHOOK_SECRET : ${{ secrets.WEBHOOK_SECRET }}
18
+ API_TOKEN : ${{ secrets.API_TOKEN }}
19
+ run : |
20
+ # Generate signature for the payload
21
+ SIGNATURE=$(echo -n "$EVENT_PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d " " -f2)
22
+ echo "SIGNATURE=$SIGNATURE" >> $GITHUB_ENV
23
+
24
+ # Create a consistent key from the webhook secret
25
+ KEY=$(echo -n "$WEBHOOK_SECRET" | openssl dgst -sha256 | cut -d ' ' -f2)
26
+
27
+ # Generate a random IV
28
+ IV=$(openssl rand -hex 16)
29
+
30
+ # Encrypt token with proper padding
31
+ ENCRYPTED_TOKEN=$(echo -n "$API_TOKEN" | openssl enc -aes-256-cbc -a -A -K "$KEY" -iv "$IV" -md sha256)
32
+
33
+ echo "ENCRYPTED_TOKEN=$ENCRYPTED_TOKEN" >> $GITHUB_ENV
34
+ echo "TOKEN_IV=$IV" >> $GITHUB_ENV
35
+
36
+ - name : Call External API (With Encrypted Token)
37
+ run : |
38
+ curl -X POST https://firstly-worthy-chamois.ngrok-free.app/github-webhook \
39
+ -H "Content-Type: application/json" \
40
+ -H "X-Hub-Signature-256: sha256=$SIGNATURE" \
41
+ -H "X-Encrypted-Token: $ENCRYPTED_TOKEN" \
42
+ -H "X-Token-IV: $TOKEN_IV" \
43
+ -d "$EVENT_PAYLOAD"
You can’t perform that action at this time.
0 commit comments