Skip to content

Commit 9ee6ede

Browse files
authored
Update python-app.yml
1 parent 39e0ce5 commit 9ee6ede

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

.github/workflows/python-app.yml

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,39 @@
11
name: PR Event Listener
2-
32
on:
43
issue_comment:
54
types: [created]
65
pull_request:
76
types: [opened, synchronize, reopened]
87
push:
9-
108
jobs:
119
process_pr_events:
1210
runs-on: ubuntu-latest
13-
1411
steps:
1512
- name: Extract event details
1613
run: echo "EVENT_PAYLOAD=$(jq -c . < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
1714

18-
- name: Generate Signature
15+
- name: Generate Signature and Encrypt Token
1916
env:
2017
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
21-
API_TOKEN: ${{ secrets.API_TOKEN }} # Token to encrypt
18+
API_TOKEN: ${{ secrets.API_TOKEN }}
2219
run: |
20+
# Generate signature for the payload
2321
SIGNATURE=$(echo -n "$EVENT_PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d " " -f2)
24-
2522
echo "SIGNATURE=$SIGNATURE" >> $GITHUB_ENV
26-
echo "API_TOKEN=$API_TOKEN" >> $GITHUB_ENV
27-
23+
24+
# Encrypt the API token using the webhook secret as encryption key
25+
# Generate a random IV for AES encryption
26+
IV=$(openssl rand -hex 16)
27+
ENCRYPTED_TOKEN=$(echo -n "$API_TOKEN" | openssl enc -aes-256-cbc -base64 -K $(echo -n "$WEBHOOK_SECRET" | xxd -p -c 64 | head -c 64) -iv $IV)
28+
29+
echo "ENCRYPTED_TOKEN=$ENCRYPTED_TOKEN" >> $GITHUB_ENV
30+
echo "TOKEN_IV=$IV" >> $GITHUB_ENV
31+
2832
- name: Call External API (With Encrypted Token)
2933
run: |
3034
curl -X POST https://firstly-worthy-chamois.ngrok-free.app/github-webhook \
3135
-H "Content-Type: application/json" \
3236
-H "X-Hub-Signature-256: sha256=$SIGNATURE" \
33-
-H "Authorization: Bearer $API_TOKEN" \
37+
-H "X-Encrypted-Token: $ENCRYPTED_TOKEN" \
38+
-H "X-Token-IV: $TOKEN_IV" \
3439
-d "$EVENT_PAYLOAD"
35-

0 commit comments

Comments
 (0)