Skip to content

Commit 1bd5256

Browse files
authored
Update python-app.yml
1 parent 697b00a commit 1bd5256

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

.github/workflows/python-app.yml

+11-28
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,17 @@
1-
name: PR Webhook Trigger
2-
3-
on:
4-
pull_request:
5-
types: [opened, synchronize, reopened]
6-
pull_request_review_comment:
7-
types: [created]
8-
91
jobs:
10-
send_webhook:
2+
process_pr_events:
113
runs-on: ubuntu-latest
124

135
steps:
14-
- name: Encrypt GitHub Token
15-
id: encrypt_token
16-
run: |
17-
ENCRYPTED_TOKEN=$(echo -n "${{ secrets.GITHUB_TOKEN }}" | base64)
18-
echo "encrypted_token=$ENCRYPTED_TOKEN" >> $GITHUB_ENV
19-
20-
- name: Generate HMAC Signature
21-
id: generate_signature
22-
run: |
23-
SECRET="${{ secrets.WEBHOOK_SECRET }}"
24-
PAYLOAD='${{ toJson(github.event) }}'
25-
SIGNATURE="sha256=$(echo -n "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET" | cut -d ' ' -f2)"
26-
echo "signature=$SIGNATURE" >> $GITHUB_ENV
6+
- name: Extract event details
7+
run: echo "EVENT_PAYLOAD=$(jq -c . < $GITHUB_EVENT_PATH)" >> $GITHUB_ENV
278

28-
- name: Send Webhook Request
9+
- name: Call External API (with HMAC signature)
10+
env:
11+
WEBHOOK_SECRET: ${{ secrets.WEBHOOK_SECRET }}
2912
run: |
30-
curl -X POST https://firstly-worthy-chamois.ngrok-free.app/github-webhook \
31-
-H "Content-Type: application/json" \
32-
-H "X-Hub-Signature-256: ${{ env.signature }}" \
33-
-H "Authorization: Bearer ${{ env.encrypted_token }}" \
34-
-d '${{ toJson(github.event) }}'
13+
SIGNATURE=$(echo -n "$EVENT_PAYLOAD" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | cut -d " " -f2)
14+
curl -X POST https://your-webhook-url/github-webhook \
15+
-H "Content-Type: application/json" \
16+
-H "X-Hub-Signature-256: sha256=$SIGNATURE" \
17+
-d "$EVENT_PAYLOAD"

0 commit comments

Comments
 (0)