Skip to content

Commit

Permalink
Build with base
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Dec 16, 2023
1 parent 3114904 commit 7091a5d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/debug-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
timeout-minutes: 20
steps:
# this is necessary so that the correct credentials are put into the git configuration
# when we push to dev-2.x and push the HTML to the git repo
# when we push to debug-client-cdn and push the HTML to the git repo
- uses: actions/checkout@v4
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x')
if: github.event_name == 'push' && (github.ref == 'refs/heads/debug-client-cdn')
with:
token: ${{ secrets.CHANGELOG_TOKEN }}
fetch-depth: 0
Expand All @@ -34,14 +34,17 @@ jobs:
with:
node-version: 18

- name: Set version
run: echo "VERSION=`date +%Y-%m-%dT%H:%M`" >> $GITHUB_ENV

- name: Build debug client
working-directory: client-next
run: |
npm install
npm run build
npm run build -- --base https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/${VERSION}/
- name: Deploy compiled assets to repo
if: github.event_name == 'push' && github.ref == 'refs/heads/dev-2.x'
if: github.event_name == 'push' && github.ref == 'refs/heads/debug-client-cdn'
env:
REMOTE: debug-client
LOCAL_BRANCH: local-assets
Expand All @@ -58,11 +61,10 @@ jobs:
git checkout $LOCAL_BRANCH
VERSION=`date +%Y-%m-%dT%H-%M`
# Copy the compiled output to a versioned folder
mkdir -p $VERSION
rsync -r client-next/output/* $VERSION
rsync -r client-next/output/* ./$VERSION/
git add $VERSION
git commit -am "Add version ${VERSION} of debug client"
Expand All @@ -73,15 +75,13 @@ jobs:
git checkout dev-2.x
git pull --rebase
# Modify the compiled output of the index.html to the CDN version
CLIENT_HTML_OUTPUT=src/client/debug-client-preview/index.html
mkdir -p src/client/debug-client-preview/
# this line is admittedly pretty unreadable it replaces the string "/debug-client-preview/" with the JsDelivr CDN URL prefix
sed "s|\/debug-client-preview\/|https:\/\/cdn.jsdelivr.net\/gh\/opentripplanner\/debug-client-assets@main\/${VERSION}\/|g" <client-next/output/index.html >${CLIENT_HTML_OUTPUT}
cp client-next/output/index.html ${CLIENT_HTML_OUTPUT}
# just to debug
cat ${CLIENT_HTML_OUTPUT}
git add ${CLIENT_HTML_OUTPUT}
git commit -m "Upgrade debug client to version ${VERSION}"
git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:dev-2.x
#git push ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git HEAD:dev-2.x
1 change: 1 addition & 0 deletions client-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,4 @@ or add it to a new `.env.development.local` file (this file will be ignored by g
In production mode, the default is to access OTP via the same origin as the client (see `.env`).
This behavior can also be modified by changing the previously mentioned environment variable at
build-time.

2 changes: 1 addition & 1 deletion client-next/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'vite';
import {defineConfig} from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
Expand Down

0 comments on commit 7091a5d

Please sign in to comment.