|
5 | 5 | push: |
6 | 6 | branches: |
7 | 7 | - master |
| 8 | + - docs-to-vector |
8 | 9 |
|
9 | 10 | jobs: |
10 | 11 | build: |
11 | 12 | runs-on: ubuntu-latest |
12 | 13 | steps: |
13 | | - - name: Call Webhook (Master) |
14 | | - if: ${{ github.ref_name == 'master' }} |
| 14 | + - name: Prepare Payload |
| 15 | + id: payload |
15 | 16 | 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 | + }') |
20 | 26 |
|
| 27 | + echo "$payload" > /tmp/payload.json |
| 28 | + |
21 | 29 | - name: Connect to company network |
22 | | - if: ${{ github.ref_name != 'master' }} |
23 | 30 | uses: tailscale/github-action@v3 |
24 | 31 | with: |
25 | 32 | oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} |
26 | 33 | oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} |
27 | 34 | tags: tag:ci |
28 | 35 |
|
29 | 36 | - name: Call Webhook (Preview) |
30 | | - if: ${{ github.ref_name != 'master' }} |
31 | 37 | 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 | + |
32 | 42 | curl -X POST \ |
33 | 43 | -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" \ |
35 | 46 | ${{ secrets.VECTOR_WEBHOOK_URL_PREVIEW }} |
36 | 47 |
|
| 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