GH Actions: fix deployment of @next
versions in /devel
#19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
# If this CI run was triggered via `repository_dispatch` from | |
# https://github.com/kaitai-io/kaitai_struct, change the run name so that it's | |
# not just "rebuild". Otherwise, return an empty string so that GitHub keeps the | |
# default name. | |
run-name: | | |
${{ (github.event_name == 'repository_dispatch' && | |
github.event.action == 'rebuild' && | |
github.event.client_payload.ksc_version) && | |
format('Build with kaitai-struct-compiler {0}', github.event.client_payload.ksc_version) || | |
'' }} | |
on: | |
push: | |
branches: | |
- master | |
- stable | |
# Allow this workflow to be run on the `master` branch when a webhook event | |
# called `repository_dispatch` is triggered. This is used from the CI workflow | |
# in https://github.com/kaitai-io/kaitai_struct to rebuild the devel Web IDE | |
# after a new version of KSC is published to npm. | |
repository_dispatch: | |
types: | |
- rebuild | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Use appropriate versions of KSC and JS runtime | |
env: | |
DIST_TAG: ${{ github.ref == 'refs/heads/master' && 'next' || 'latest' }} | |
# `--package-lock-only` means that it only updates `package-lock.json` | |
# (and `package.json`) without touching `node_modules/` at all. | |
run: | | |
npm install --package-lock-only kaitai-struct-compiler@"$DIST_TAG" kaitai-struct@"$DIST_TAG" | |
# NOTE: it's important that `npm ci` is run *after* the adjustment of | |
# KSC's and JS runtime's versions so that the `install` script (`node | |
# vendor_build.js`) copies the correct versions into the `lib/_npm/` | |
# folder which will be deployed. | |
- run: npm ci | |
- name: Set up environment variables for stable deployment | |
run: | | |
echo 'SENTRY_ENV=stable' >> "$GITHUB_ENV" | |
if: github.ref == 'refs/heads/stable' | |
- name: Set up environment variables for devel deployment | |
run: | | |
echo 'SENTRY_ENV=devel' >> "$GITHUB_ENV" | |
if: github.ref == 'refs/heads/master' | |
- name: Build | |
env: | |
SENTRY_DSN: 'https://[email protected]/202888' | |
run: ./build | |
- name: Deploy | |
env: | |
BOT_SSH_KEY: ${{secrets.BOT_SSH_KEY}} | |
OUTDIR: ${{ github.ref == 'refs/heads/master' && 'devel' || '' }} | |
run: | | |
./push_artifacts/git_config_kaitai_bot | |
./push_artifacts/publish \ | |
-o kaitai-io \ | |
-r ide-kaitai-io.github.io \ | |
-d "$OUTDIR" \ | |
-m "Regen ${GITHUB_REF#refs/heads/*} $GITHUB_REPOSITORY@$GITHUB_SHA" \ | |
-- \ | |
--exclude=.git \ | |
--exclude=.github/ \ | |
--exclude=.nojekyll \ | |
--exclude=_build/ \ | |
--exclude=CNAME \ | |
--exclude=favicon.ico \ | |
--exclude=favicon.ico.license \ | |
--exclude=devel/ \ | |
out/ |