Refactored payload preparation in GitHub Actions workflow to use jq f… #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docs to Vector | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| - docs-to-vector | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Prepare Payload | |
| id: payload | |
| run: | | |
| payload=$(jq -n \ | |
| --arg current_commit_id "${{ github.sha }}" \ | |
| --arg repo_name "${{ github.event.repository.name }}" \ | |
| '{ | |
| current_commit_id: $current_commit_id, | |
| repo_name: $repo_name, | |
| }') | |
| echo "PAYLOAD=$payload" >> $GITHUB_OUTPUT | |
| - name: Call Webhook (Master) | |
| if: ${{ github.ref_name == 'master' }} | |
| run: | | |
| payload=${{ steps.payload.outputs.PAYLOAD }} | |
| sig=$(printf '%s' "$payload" | \ | |
| openssl dgst -sha256 -hmac "${{ secrets.VECTOR_WEBHOOK_SECRET }}" -binary | xxd -p -c 256) | |
| curl -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-Hub-Signature-256: sha256=$sig" \ | |
| -d "$payload" \ | |
| ${{ secrets.VECTOR_WEBHOOK_URL }} | |
| - name: Connect to company network | |
| if: ${{ github.ref_name != 'master' }} | |
| uses: tailscale/github-action@v3 | |
| with: | |
| oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} | |
| oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} | |
| tags: tag:ci | |
| - name: Call Webhook (Preview) | |
| if: ${{ github.ref_name != 'master' }} | |
| run: | | |
| payload=${{ steps.payload.outputs.PAYLOAD }} | |
| sig=$(printf '%s' "$payload" | \ | |
| openssl dgst -sha256 -hmac "${{ secrets.VECTOR_WEBHOOK_SECRET_PREVIEW }}" -binary | xxd -p -c 256) | |
| curl -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -H "X-Hub-Signature-256: sha256=$sig" \ | |
| -d "$payload" \ | |
| ${{ secrets.VECTOR_WEBHOOK_URL_PREVIEW }} | |