Skip to content

Commit

Permalink
Trigger ide.kaitai.io/devel rebuild after NPM publish (#1124)
Browse files Browse the repository at this point in the history
* Trigger ide.kaitai.io/devel rebuild after NPM publish

* updates from review

* update workflow

* cleanup

* GH Actions: fix mismatched environment variable name

* trigger-kaitai_struct_webide: also send KSC version

Required by kaitai-io/kaitai_struct_webide@f968ac3

---------

Co-authored-by: Petr Pucil <[email protected]>
  • Loading branch information
jtbandes and generalmimon authored Aug 23, 2024
1 parent 8102887 commit 107fe14
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
40 changes: 20 additions & 20 deletions trigger-kaitai_struct_webide
Original file line number Diff line number Diff line change
@@ -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 <ksc_version>"
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

0 comments on commit 107fe14

Please sign in to comment.