Skip to content

Commit e7ac852

Browse files
committed
Deploy
1 parent 2ca17b7 commit e7ac852

File tree

4 files changed

+65
-1
lines changed

4 files changed

+65
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Deploy demo page
2+
on:
3+
# Runs on pushes targeting the default branch
4+
push:
5+
branches: ['main']
6+
# Allows you to run this workflow manually from the Actions tab
7+
workflow_dispatch:
8+
9+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
jobs:
16+
deploy:
17+
environment:
18+
name: github-pages
19+
url: ${{ steps.deployment.outputs.page_url }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
- uses: oven-sh/setup-bun@v1
24+
with:
25+
bun-version: latest
26+
- run: |
27+
bun install --frozen-lockfile
28+
bun run ci
29+
bun run build
30+
bun run demo:nyc
31+
bun run demo:publish
32+
env:
33+
CI: true
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v5
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: 'dist'
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v4

bun.lockb

-16 Bytes
Binary file not shown.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"build": "bun run --cwd packages/reporter build",
1212
"demo:nyc": "bun run --cwd packages/example test:nyc",
1313
"demo:c8": "bun run --cwd packages/example test:c8",
14-
"demo:preview": "http-server packages/example/coverage"
14+
"demo:preview": "http-server packages/example/coverage",
15+
"demo:publish": "bun ./scripts/copy.ts"
1516
},
1617
"lint-staged": {
1718
"*.{js,ts}": "biome check --apply",

scripts/copy.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import fs from "node:fs";
2+
import path from "node:path";
3+
4+
const coverageDirectory = path.join(__dirname, "../packages/example/coverage");
5+
const outputDirectory = path.join(__dirname, "../dist");
6+
fs.cpSync(coverageDirectory, outputDirectory, { recursive: true });
7+
8+
const indexHTMLPath = path.join(outputDirectory, "index.html");
9+
const indexHTML = fs.readFileSync(indexHTMLPath, "utf-8");
10+
11+
fs.writeFileSync(
12+
indexHTMLPath,
13+
indexHTML.replace(
14+
"<head>",
15+
`
16+
<head>
17+
<base href="/coverage-pretty-html-reporter/" />
18+
`,
19+
),
20+
"utf-8",
21+
);

0 commit comments

Comments
 (0)