diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4172b92c..c3ad9bd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,12 @@ jobs: env: NPM_API_KEY: ${{ secrets.NPM_TOKEN }} + - name: trigger rebuild of ide.kaitai.io/devel + 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 }} + - name: publish ksc to artifacts uses: actions/upload-artifact@v4 with: diff --git a/trigger-kaitai_struct_webide b/trigger-kaitai_struct_webide index 1ae4362a..737c0142 100755 --- a/trigger-kaitai_struct_webide +++ b/trigger-kaitai_struct_webide @@ -1,31 +1,31 @@ #!/bin/sh -ef -# https://travis-ci.com/kaitai-io/kaitai_struct_webide 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 " + exit 1 +fi + +ksc_version=$1 PROJECT='kaitai-io/kaitai_struct_webide' -SLUG=$(echo "$PROJECT" | sed 's,/,%2F,g') echo "Triggering build for $PROJECT project..." -if [ -n "$KAITAI_STRUCT_WEBIDE_TOKEN" ]; then - body=' - { - "request": { - "message": "Build with kaitai-struct-compiler v'"$KAITAI_STRUCT_VERSION"'", - "branch": "master" - } - } - ' +if [ -n "$KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" ]; then + # `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 \ - -H "Content-Type: application/json" \ - -H "Accept: application/json" \ - -H "Travis-API-Version: 3" \ - -H "Authorization: token $KAITAI_STRUCT_WEBIDE_TOKEN" \ + curl -fsSL \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer $KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ -d "$body" \ - "https://api.travis-ci.com/repo/$SLUG/requests" + "https://api.github.com/repos/$PROJECT/dispatches" else - echo "No KAITAI_STRUCT_WEBIDE_TOKEN found!" + echo "No KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN found!" + exit 1 fi