Skip to content

Commit 4e4d4bf

Browse files
committed
Updated GitHub Actions workflow to streamline webhook calls by consolidating logic for master and non-master branches, ensuring consistent payload handling and signature generation.
1 parent 67e82e5 commit 4e4d4bf

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,24 @@ jobs:
1616
run: |
1717
payload=$(jq -n \
1818
--arg current_commit_id "${{ github.sha }}" \
19+
--arg branch_name "${{ github.ref_name }}" \
1920
--arg repo_name "${{ github.event.repository.name }}" \
2021
'{
2122
current_commit_id: $current_commit_id,
23+
branch_name: $branch_name,
2224
repo_name: $repo_name,
2325
}')
2426
2527
echo "$payload" > /tmp/payload.json
2628
27-
28-
- name: Call Webhook (Master)
29-
if: ${{ github.ref_name == 'master' }}
30-
run: |
31-
payload=$(cat /tmp/payload.json)
32-
sig=$(printf '%s' "$payload" | \
33-
openssl dgst -sha256 -hmac "${{ secrets.VECTOR_WEBHOOK_SECRET }}" -binary | xxd -p -c 256)
34-
35-
curl -X POST \
36-
-H "Content-Type: application/json" \
37-
-H "X-Hub-Signature-256: sha256=$sig" \
38-
-d "$payload" \
39-
${{ secrets.VECTOR_WEBHOOK_URL }}
40-
4129
- name: Connect to company network
42-
if: ${{ github.ref_name != 'master' }}
4330
uses: tailscale/github-action@v3
4431
with:
4532
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
4633
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
4734
tags: tag:ci
4835

4936
- name: Call Webhook (Preview)
50-
if: ${{ github.ref_name != 'master' }}
5137
run: |
5238
payload=$(cat /tmp/payload.json)
5339
sig=$(printf '%s' "$payload" | \
@@ -59,3 +45,15 @@ jobs:
5945
-d "$payload" \
6046
${{ secrets.VECTOR_WEBHOOK_URL_PREVIEW }}
6147
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)