Skip to content

Commit f973e66

Browse files
committed
Refactor GitHub Actions workflow to enhance webhook payload structure and add support for 'docs-to-vector' branch. The payload now includes repository name and uses HMAC for signature verification.
1 parent f2f7971 commit f973e66

File tree

1 file changed

+32
-9
lines changed

1 file changed

+32
-9
lines changed

.github/workflows/docs-to-vector.yml

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,55 @@ on:
55
push:
66
branches:
77
- master
8+
- docs-to-vector
89

910
jobs:
1011
build:
1112
runs-on: ubuntu-latest
1213
steps:
13-
- name: Call Webhook (Master)
14-
if: ${{ github.ref_name == 'master' }}
14+
- name: Prepare Payload
15+
id: payload
1516
run: |
16-
curl -X POST \
17-
-H "Content-Type: application/json" \
18-
-d '{"commit_id": "${{ github.sha }}", "branch": "${{ github.ref_name }}"}' \
19-
${{ secrets.VECTOR_WEBHOOK_URL }}
17+
payload=$(jq -n \
18+
--arg current_commit_id "${{ github.sha }}" \
19+
--arg branch_name "${{ github.ref_name }}" \
20+
--arg repo_name "${{ github.event.repository.name }}" \
21+
'{
22+
current_commit_id: $current_commit_id,
23+
branch_name: $branch_name,
24+
repo_name: $repo_name,
25+
}')
2026
27+
echo "$payload" > /tmp/payload.json
28+
2129
- name: Connect to company network
22-
if: ${{ github.ref_name != 'master' }}
2330
uses: tailscale/github-action@v3
2431
with:
2532
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
2633
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
2734
tags: tag:ci
2835

2936
- name: Call Webhook (Preview)
30-
if: ${{ github.ref_name != 'master' }}
3137
run: |
38+
payload=$(cat /tmp/payload.json)
39+
sig=$(printf '%s' "$payload" | \
40+
openssl dgst -sha256 -hmac "${{ secrets.VECTOR_WEBHOOK_SECRET_PREVIEW }}" -binary | xxd -p -c 256)
41+
3242
curl -X POST \
3343
-H "Content-Type: application/json" \
34-
-d '{"commit_id": "${{ github.sha }}", "branch": "${{ github.ref_name }}"}' \
44+
-H "X-Hub-Signature-256: sha256=$sig" \
45+
-d "$payload" \
3546
${{ secrets.VECTOR_WEBHOOK_URL_PREVIEW }}
3647
48+
- name: Call Webhook (Master)
49+
if: ${{ github.ref_name == 'master' }}
50+
run: |
51+
payload=$(cat /tmp/payload.json)
52+
sig=$(printf '%s' "$payload" | \
53+
openssl dgst -sha256 -hmac "${{ secrets.VECTOR_WEBHOOK_SECRET }}" -binary | xxd -p -c 256)
54+
55+
curl -X POST \
56+
-H "Content-Type: application/json" \
57+
-H "X-Hub-Signature-256: sha256=$sig" \
58+
-d "$payload" \
59+
${{ secrets.VECTOR_WEBHOOK_URL }}

0 commit comments

Comments
 (0)