Skip to content

Commit

Permalink
fix and improve env var usage
Browse files Browse the repository at this point in the history
  • Loading branch information
wassfila committed Apr 21, 2024
1 parent 67bf465 commit 09b3bd1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
env:
PUBLIC_BASE: /pipeline-visualization
steps:
- name: Checkout your repository using git
uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions website/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm run build
13 changes: 3 additions & 10 deletions website/config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import {readFile} from 'fs/promises'
import {join} from 'path'
import yaml from 'js-yaml'

async function load_yaml_abs(abs_path){
const fileContent = await readFile(abs_path,'utf-8')
const data = yaml.load(fileContent);
return data;
}
import {loadEnv} from 'vite'

const webdir = process.cwd()
const env = loadEnv("",webdir,"PUBLIC_BASE")
const rootdir = join(webdir,"..")
const cachedir = join(rootdir,"cache")
const manifets = await load_yaml_abs(join(rootdir,"manifest.yaml"))
const outdir = join(cachedir,"web")
const base = manifets.website.base
const base = env.PUBLIC_BASE

const config = {
rootdir,
Expand Down
3 changes: 2 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"astro": "^4.6.3",
"js-yaml": "^4.1.0",
"vis-data": "^7.1.9",
"vis-timeline": "^7.7.3"
"vis-timeline": "^7.7.3",
"vite": "^5.2.10"
}
}
3 changes: 3 additions & 0 deletions website/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion website/src/components/timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ async function init(){
for (const timeline_element of containers_els) {
const data_file = timeline_element.dataset.file;
try {
const response = await fetch(`${config.base}/artifacts/${data_file}`);
const file_url = `${config.base}/artifacts/${data_file}`
console.log(`fetching ${file_url}`)
const response = await fetch(file_url);
const data_timeline = await response.json(); // Assuming the response needs to be converted to JSON
new Timeline(timeline_element, data_timeline, {})
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions website/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />

0 comments on commit 09b3bd1

Please sign in to comment.