Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger ide.kaitai.io/devel rebuild after NPM publish #1124

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading