Skip to content

Commit d60c566

Browse files
authored
Refactor event dispatch to use JSON payload
Updated the GitHub Actions workflow to use a JSON payload for dispatching events instead of a hardcoded string.
1 parent c7fafba commit d60c566

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

.github/workflows/send-beta-build.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ permissions:
1313
contents: read
1414

1515
jobs:
16-
build-and-dispatch:
16+
send:
1717
runs-on: ubuntu-latest
1818
outputs:
1919
artifact-url: ${{ steps.get-artifact.outputs.url }}
@@ -101,17 +101,18 @@ jobs:
101101
echo " artifact_url: ${ARTIFACT_URL}"
102102
echo " zip_name: ${ZIP_NAME}"
103103
104+
JSON=$(jq -n \
105+
--arg event_type "deploy-build" \
106+
--arg source_repo "${{ github.repository }}" \
107+
--arg artifact_url "$ARTIFACT_URL" \
108+
--arg token "${{ secrets.GITHUB_TOKEN }}" \
109+
--arg subfolder "$SUBFOLDER" \
110+
--arg zip_name "$ZIP_NAME" \
111+
'{event_type: $event_type, client_payload: {source_repo: $source_repo, artifact_url: $artifact_url, token: $token, subfolder: $subfolder, zip_name: $zip_name}}' \
112+
)
113+
104114
curl -X POST \
105115
-H "Authorization: token ${{ secrets.BETA_PAT_TOKEN }}" \
106116
-H "Accept: application/vnd.github+json" \
107117
https://api.github.com/repos/${BETA_REPO}/dispatches \
108-
-d '{
109-
"event_type": "deploy-build",
110-
"client_payload": {
111-
"source_repo": "'"${{ github.repository }}"'",
112-
"artifact_url": "'"${ARTIFACT_URL}"'",
113-
"token": "'"${{ secrets.GITHUB_TOKEN }}"'",
114-
"subfolder": "'"${SUBFOLDER}"'",
115-
"zip_name": "'"${ZIP_NAME}"'"
116-
}
117-
}'
118+
-d "$JSON"

0 commit comments

Comments
 (0)