Skip to content

Commit

Permalink
trigger-kaitai_struct_webide: also send KSC version
Browse files Browse the repository at this point in the history
  • Loading branch information
generalmimon committed Aug 23, 2024
1 parent 49d1b44 commit 4ed256b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ jobs:
NPM_API_KEY: ${{ secrets.NPM_TOKEN }}

- name: trigger rebuild of ide.kaitai.io/devel
run: ./trigger-kaitai_struct_webide
run: |
./trigger-kaitai_struct_webide "$(jq -r .version compiler/js/npm/package.json)"
env:
KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN: ${{ secrets.KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN }}

Expand Down
19 changes: 13 additions & 6 deletions trigger-kaitai_struct_webide
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
#!/bin/sh -ef

# ide.kaitai.io/devel needs to be rebuilt after we publish newest JS build of ksc to npm.
# ide.kaitai.io/devel needs to be rebuilt after we publish the latest JS build of KSC to npm.

if [ "$#" -ne 1 ]; then
echo "Usage: $0 <ksc_version>"
exit 1
fi

ksc_version=$1

PROJECT='kaitai-io/kaitai_struct_webide'

echo "Triggering build for $PROJECT project..."
if [ -n "$KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" ]; then
# Matches the type in kaitai_struct_webide's repository_dispatch trigger
body='{"event_type":"rebuild"}'
# `event_type` must match the name whitelisted in the CI workflow config in
# https://github.com/kaitai-io/kaitai_struct_webide
body=$(jq -n -c --arg ksc_version "$ksc_version" '{event_type: "rebuild", client_payload: {ksc_version: $ksc_version}}')

echo "$body"
printf '%s\n' "$body"

curl -v -fsSL \
-X POST \
curl -fsSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
Expand Down

0 comments on commit 4ed256b

Please sign in to comment.