From 12ed378cc23bb9038f3b905520d08ab1c23f0125 Mon Sep 17 00:00:00 2001 From: Alessandro Pignotti Date: Tue, 15 Oct 2024 11:17:07 +0200 Subject: [PATCH] GitHub: First attempt at GH pages deployment --- .github/workflows/deploy.yml | 37 +++++++++++++++++++++--------------- config_github_terminal.js | 23 ++++++++++++++++++++++ vite.config.js | 2 +- 3 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 config_github_terminal.js diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d1eb72d..7e7e4f6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -164,28 +164,35 @@ jobs: sudo umount /mnt/ # Result is an ext2 image for webvm. - # Move required files for gh-pages deployment to the deployment directory $DEPLOY_DIR. - - run: sudo mv assets examples xterm favicon.ico index.html login.html network.js scrollbar.css serviceWorker.js tower.ico $DEPLOY_DIR - # The .txt suffix enabled HTTP compression for free - name: Generate image split chunks and .meta file run: | sudo split ${{ env.IMAGE_NAME }} ${{ env.DEPLOY_DIR }}/${{ env.IMAGE_NAME }}.c -a 6 -b 128k -x --additional-suffix=.txt sudo bash -c "stat -c%s ${{ env.IMAGE_NAME }} > ${{ env.DEPLOY_DIR }}/${{ env.IMAGE_NAME }}.meta" - # This step updates the default index.html file by performing the following actions: + + # This step updates the default config_github_terminal.js file by performing the following actions: # 1. Replaces all occurrences of IMAGE_URL with the URL to the image. - # 2. Replaces all occurrences of DEVICE_TYPE to bytes. - # 3. Replace CMD with the Dockerfile entry command. - # 4. Replace args with the Dockerfile CMD / Entrypoint args. - # 5. Replace ENV with the container's environment values. - - name: Adjust index.html + # 2. Replace CMD with the Dockerfile entry command. + # 3. Replace args with the Dockerfile CMD / Entrypoint args. + # 4. Replace ENV with the container's environment values. + # 5. Replace CWD with the container's current working directory. + - name: Adjust config_github_terminal.js run: | - sudo sed -i 's#IMAGE_URL#"${{ env.IMAGE_NAME }}"#g' ${{ env.DEPLOY_DIR }}index.html - sudo sed -i 's#DEVICE_TYPE#"github"#g' ${{ env.DEPLOY_DIR }}index.html - sudo sed -i 's#CMD#${{ env.CMD }}#g' ${{ env.DEPLOY_DIR }}index.html - sudo sed -i 's#ARGS#${{ env.ARGS }}#g' ${{ env.DEPLOY_DIR }}index.html - sudo sed -i 's#ENV#${{ env.ENV }}#g' ${{ env.DEPLOY_DIR }}index.html - sudo sed -i 's#CWD#${{ env.CWD }}#g' ${{ env.DEPLOY_DIR }}index.html + sed -i 's#IMAGE_URL#"${{ env.IMAGE_NAME }}"#g' config_github_terminal.js + sed -i 's#CMD#${{ env.CMD }}#g' config_github_terminal.js + sed -i 's#ARGS#${{ env.ARGS }}#g' config_github_terminal.js + sed -i 's#ENV#${{ env.ENV }}#g' config_github_terminal.js + sed -i 's#CWD#${{ env.CWD }}#g' config_github_terminal.js + # Debug + cat config_github_terminal.js + + - name: Build NPM package + run: | + npm install + WEBVM_MODE=github npm build run + + # Move required files for gh-pages deployment to the deployment directory $DEPLOY_DIR. + - run: mv build $DEPLOY_DIR # We generate index.list files for our httpfs to function properly. - name: make index.list diff --git a/config_github_terminal.js b/config_github_terminal.js new file mode 100644 index 0000000..d356f2e --- /dev/null +++ b/config_github_terminal.js @@ -0,0 +1,23 @@ +// The root filesystem location +export const diskImageUrl = IMAGE_URL; +// The root filesystem backend type +export const diskImageType = "github"; +// Print an introduction message about the technology +export const printIntro = true; +// Is a graphical display needed +export const needsDisplay = false; +// Executable full path (Required) +export const cmd = CMD; +// Arguments, as an array (Required) +export const args = ARGS; +// Optional extra parameters +export const opts = { + // Environment variables + env: ENV; + // Current working directory + cwd: CWD; + // User id + uid: 1000, + // Group id + gid: 1000 +}; diff --git a/vite.config.js b/vite.config.js index 05a5e6d..3a69abb 100644 --- a/vite.config.js +++ b/vite.config.js @@ -5,7 +5,7 @@ import { viteStaticCopy } from 'vite-plugin-static-copy'; export default defineConfig({ resolve: { alias: { - '/config_terminal': 'config_public_terminal.js' + '/config_terminal': process.env.WEBVM_MODE == "github" ? 'config_github_terminal.js' : 'config_public_terminal.js' } }, build: {