-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (32 loc) · 1.27 KB
/
python-app.yml
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
name: PR Event Listener
on:
issue_comment:
types: [created]
pull_request:
types: [opened, synchronize, reopened]
push:
jobs:
process_pr_events:
runs-on: ubuntu-latest
steps:
- name: Extract event details
run: echo "EVENT_PAYLOAD=$(jq -c . < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
- name: Generate Encrypted Token
env:
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
API_TOKEN: ${{ secrets.API_TOKEN }} # Token to encrypt
run: |
SIGNATURE=$(echo -n "$EVENT_PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d " " -f2)
ENCRYPTED_TOKEN=$(echo -n "$API_TOKEN" | openssl enc -aes-256-cbc -a -salt -pbkdf2 -pass pass:"$WEBHOOK_SECRET")
echo $WEBHOOK_SECRET
echo $API_TOKEN
echo $ENCRYPTED_TOKEN
echo "SIGNATURE=$SIGNATURE" >> $GITHUB_ENV
echo "ENCRYPTED_TOKEN=$ENCRYPTED_TOKEN" >> $GITHUB_ENV
- name: Call External API (With Encrypted Token)
run: |
curl -X POST https://firstly-worthy-chamois.ngrok-free.app/github-webhook \
-H "Content-Type: application/json" \
-H "X-Hub-Signature-256: sha256=$SIGNATURE" \
-H "Authorization: Bearer $ENCRYPTED_TOKEN" \
-d "$EVENT_PAYLOAD"