From f3699fb1952d3a3dbafe8a01677af64238df2063 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Thu, 15 Aug 2024 13:45:21 -0700 Subject: [PATCH 1/6] Trigger ide.kaitai.io/devel rebuild after NPM publish --- .github/workflows/main.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4172b92c..2f89dd86 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,6 +44,14 @@ jobs: env: NPM_API_KEY: ${{ secrets.NPM_TOKEN }} + - name: trigger rebuild of ide.kaitai.io/devel + uses: octokit/request-action@v2.3.1 + env: + GITHUB_TOKEN: ${{ secrets.KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN }} + with: + route: POST /repos/kaitai-io/kaitai_struct_webide/dispatches + event_type: rebuild-webide # this value is required but unused + - name: publish ksc to artifacts uses: actions/upload-artifact@v4 with: From 5aae72d077dcb179e26603cfb811516647a4320e Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Fri, 16 Aug 2024 12:46:51 -0700 Subject: [PATCH 2/6] updates from review --- trigger-kaitai_struct_webide | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/trigger-kaitai_struct_webide b/trigger-kaitai_struct_webide index 1ae4362a..91e2167b 100755 --- a/trigger-kaitai_struct_webide +++ b/trigger-kaitai_struct_webide @@ -1,31 +1,23 @@ #!/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 newest JS build of ksc to npm. 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 + # Matches the type in kaitai_struct_webide's repository_dispatch trigger + body='{"event_type":"rebuild"}' echo "$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" \ + -X POST \ + -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/kaitai-io/kaitai_struct_webide/dispatches" else - echo "No KAITAI_STRUCT_WEBIDE_TOKEN found!" + echo "No KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN found!" fi From caff16770328a26407a796445319ab4fba76ecf6 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Fri, 16 Aug 2024 12:48:09 -0700 Subject: [PATCH 3/6] update workflow --- .github/workflows/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f89dd86..ce9a6cc9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,12 +45,9 @@ jobs: NPM_API_KEY: ${{ secrets.NPM_TOKEN }} - name: trigger rebuild of ide.kaitai.io/devel - uses: octokit/request-action@v2.3.1 + run: ./trigger-kaitai_struct_webide env: GITHUB_TOKEN: ${{ secrets.KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN }} - with: - route: POST /repos/kaitai-io/kaitai_struct_webide/dispatches - event_type: rebuild-webide # this value is required but unused - name: publish ksc to artifacts uses: actions/upload-artifact@v4 From 7d3ad528edbd52b437cb3f93df75fad1f662e4c9 Mon Sep 17 00:00:00 2001 From: Jacob Bandes-Storch Date: Fri, 16 Aug 2024 13:47:25 -0700 Subject: [PATCH 4/6] cleanup --- trigger-kaitai_struct_webide | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trigger-kaitai_struct_webide b/trigger-kaitai_struct_webide index 91e2167b..61a9a5c1 100755 --- a/trigger-kaitai_struct_webide +++ b/trigger-kaitai_struct_webide @@ -17,7 +17,7 @@ if [ -n "$KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" ]; then -H "Authorization: Bearer $KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ -d "$body" \ - "https://api.github.com/repos/kaitai-io/kaitai_struct_webide/dispatches" + "https://api.github.com/repos/$PROJECT/dispatches" else echo "No KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN found!" fi From 49d1b44ce692a02c519ae874f6603e62d2c9d858 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Fri, 23 Aug 2024 23:52:26 +0200 Subject: [PATCH 5/6] GH Actions: fix mismatched environment variable name --- .github/workflows/main.yml | 2 +- trigger-kaitai_struct_webide | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce9a6cc9..ea660f16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,7 +47,7 @@ jobs: - name: trigger rebuild of ide.kaitai.io/devel run: ./trigger-kaitai_struct_webide env: - GITHUB_TOKEN: ${{ secrets.KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN }} + KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN: ${{ secrets.KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN }} - name: publish ksc to artifacts uses: actions/upload-artifact@v4 diff --git a/trigger-kaitai_struct_webide b/trigger-kaitai_struct_webide index 61a9a5c1..5383bf8d 100755 --- a/trigger-kaitai_struct_webide +++ b/trigger-kaitai_struct_webide @@ -20,4 +20,5 @@ if [ -n "$KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN" ]; then "https://api.github.com/repos/$PROJECT/dispatches" else echo "No KAITAI_STRUCT_WEBIDE_GITHUB_TOKEN found!" + exit 1 fi From 4ed256b016684c2f2bf8717c5f2b6d2287c2e9c1 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Sat, 24 Aug 2024 00:04:49 +0200 Subject: [PATCH 6/6] trigger-kaitai_struct_webide: also send KSC version Required by https://github.com/kaitai-io/kaitai_struct_webide/commit/f968ac3b23b685b10637f2382bd6f3fef9cf5ea3 --- .github/workflows/main.yml | 3 ++- trigger-kaitai_struct_webide | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea660f16..c3ad9bd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 }} diff --git a/trigger-kaitai_struct_webide b/trigger-kaitai_struct_webide index 5383bf8d..737c0142 100755 --- a/trigger-kaitai_struct_webide +++ b/trigger-kaitai_struct_webide @@ -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 " + 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" \