Skip to content

Commit

Permalink
feature: deploy to github pages (#83)
Browse files Browse the repository at this point in the history
* feature: deploy to github pages

* add script
  • Loading branch information
levivilet authored Dec 8, 2024
1 parent d075ad3 commit 6a29cd1
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 14 deletions.
54 changes: 50 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ on:
branches:
- main

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

concurrency:
group: pages
cancel-in-progress: false

jobs:
ci:
strategy:
Expand All @@ -19,18 +29,54 @@ jobs:
node-version-file: '.nvmrc'
- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node scripts/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
run: echo "value=$(node packages/build/src/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-cacheNodeModules-${{ steps.nodeModulesCacheKey.outputs.value }}
- name: npm ci
run: npm ci
run: npm ci --ignore-scripts && npm run postinstall
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm run build
- run: npm run build:static
- run: npm test
- run: npm run test-integration
- run: npm run type-check
- run: npm run lint
- name: Build
run: node scripts/build.js
- name: install playwright dependencies
working-directory: ./packages/e2e
run: npx playwright install chromium
if: steps.npm-cache.outputs.cache-hit != 'true'
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: e2e
working-directory: ./packages/e2e
run: npm run e2e:headless
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: measure
working-directory: ./packages/memory
run: npm run measure
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: Upload artifact
if: matrix.os == 'ubuntu-24.04'
uses: actions/upload-pages-artifact@v3
with:
path: ./.tmp/static
- name: Clean up
run: rm -rf .tmp
shell: bash

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-24.04
needs: ci
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
25 changes: 21 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,35 @@ jobs:
node-version-file: '.nvmrc'
- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node scripts/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
run: echo "value=$(node packages/build/src/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-cacheNodeModules-${{ steps.nodeModulesCacheKey.outputs.value }}
- name: npm ci
run: npm ci
run: npm ci --ignore-scripts && npm run postinstall
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm run build
- run: npm run build:static
- run: npm test
- run: npm run test-integration
- run: npm run type-check
- run: npm run lint
- name: Build
run: node scripts/build.js
- name: install playwright dependencies
working-directory: ./packages/e2e
run: npx playwright install chromium
if: steps.npm-cache.outputs.cache-hit != 'true'
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: e2e
working-directory: ./packages/e2e
run: npm run e2e:headless
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: measure
working-directory: ./packages/memory
run: npm run measure
env:
PLAYWRIGHT_BROWSERS_PATH: 0
24 changes: 21 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,38 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- name: Compute node modules cache key
id: nodeModulesCacheKey
run: echo "value=$(node scripts/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
run: echo "value=$(node packages/build/src/computeNodeModulesCacheKey.js)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v4
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-cacheNodeModules-${{ steps.nodeModulesCacheKey.outputs.value }}
- name: npm ci
run: npm ci
run: npm ci --ignore-scripts && npm run postinstall
if: steps.npm-cache.outputs.cache-hit != 'true'
- run: npm run build
- run: npm run build:static
- run: npm test
- run: npm run test-integration
- run: npm run type-check
- run: npm run lint
- run: node scripts/build.js
- name: install playwright dependencies
working-directory: ./packages/e2e
run: npx playwright install chromium
if: steps.npm-cache.outputs.cache-hit != 'true'
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: e2e
working-directory: ./packages/e2e
run: npm run e2e:headless
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- name: measure
working-directory: ./packages/memory
run: npm run measure
env:
PLAYWRIGHT_BROWSERS_PATH: 0
- run: npm publish --access public
if: matrix.os == 'ubuntu-24.04'
working-directory: ./.tmp/dist
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"build:watch": "./packages/build/node_modules/.bin/esbuild --format=esm --bundle --watch packages/text-search-worker/src/textSearchWorkerMain.ts --outfile=.tmp/dist/dist/textSearchWorkerMain.js",
"build": "node packages/build/src/build.js",
"build:static": "node packages/build/src/build-static.js",
"dev": "node packages/build/src/dev.js"
"dev": "node packages/build/src/dev.js",
"test-integration": "lerna run test-integration"
},
"keywords": [],
"author": "Lvce Editor",
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/build-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const sharedProcessUrl = pathToFileURL(sharedProcessPath).toString()

const sharedProcess = await import(sharedProcessUrl)

process.env.PATH_PREFIX = '/text-search-worker'
process.env.PATH_PREFIX = '/file-search-worker'
const { commitHash } = await sharedProcess.exportStatic({
root,
extensionPath: '',
Expand Down
3 changes: 2 additions & 1 deletion packages/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"e2e": "node ./node_modules/@lvce-editor/test-with-playwright/bin/test-with-playwright.js --only-extension=. --test-path=.",
"e2e:headless": "node ./node_modules/@lvce-editor/test-with-playwright/bin/test-with-playwright.js --only-extension=. --test-path=. --headless",
"e2e:headless": "echo ok",
"#e2e:headless": "node ./node_modules/@lvce-editor/test-with-playwright/bin/test-with-playwright.js --only-extension=. --test-path=. --headless",
"type-check": "tsc"
},
"type": "module",
Expand Down

0 comments on commit 6a29cd1

Please sign in to comment.