Skip to content

Commit a63307b

Browse files
committed
ci: deploy to GitHub Pages
1 parent 8eaca3a commit a63307b

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

.github/workflows/deploy.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
name: Build Docusaurus
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 18
19+
cache: yarn
20+
21+
- name: Install dependencies
22+
run: yarn install --frozen-lockfile
23+
- name: Build website
24+
run: yarn build
25+
26+
- name: Upload Build Artifact
27+
uses: actions/upload-pages-artifact@v3
28+
with:
29+
path: build
30+
31+
deploy:
32+
name: Deploy to GitHub Pages
33+
needs: build
34+
35+
permissions:
36+
pages: write
37+
id-token: write
38+
39+
environment:
40+
name: github-pages
41+
url: ${{ steps.deployment.outputs.page_url }}
42+
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Deploy to GitHub Pages
46+
id: deployment
47+
uses: actions/deploy-pages@v4

docusaurus.config.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import versions from './versions.json';
1313

1414
const isDev = process.env.NODE_ENV === 'development';
1515
const isBuildFast = isDev || !!process.env.BUILD_FAST;
16-
const isNetlify = !!process.env.NETLIFY;
17-
const isProd = isNetlify && process.env.CONTEXT === 'production';
16+
const isProd =
17+
process.env.CURRENT_BRANCH === 'main' && process.env.CONTEXT === 'production';
1818

1919
const config: Config = {
20+
organizationName: 'someengineering',
21+
projectName: 'inventory.fix.security',
22+
deploymentBranch: 'gh-pages',
2023
title: 'Fix Inventory by Some Engineering Inc.',
2124
url: 'https://inventory.fix.security',
2225
baseUrl: '/',
@@ -29,14 +32,13 @@ const config: Config = {
2932
noIndex: !isProd,
3033
customFields: {
3134
isDev,
32-
isNetlify,
3335
isProd,
3436
posthogProjectApiKey: process.env.POSTHOG_PROJECT_API_KEY,
3537
},
3638
scripts: isProd
3739
? [
3840
{
39-
src: 'https://inventory.fix.security/js/script.js',
41+
src: 'https://plausible.io/js/script.js',
4042
defer: true,
4143
'data-domain': 'inventory.fix.security',
4244
},

src/providers/posthog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ export default function PosthogProvider({
1010
}) {
1111
const {
1212
siteConfig: {
13-
customFields: { isDev, isNetlify, isProd, posthogProjectApiKey },
13+
customFields: { isDev, isProd, posthogProjectApiKey },
1414
},
1515
} = useDocusaurusContext();
1616

1717
useEffect(() => {
1818
if (posthogProjectApiKey && !posthog.__loaded) {
1919
posthog.init(posthogProjectApiKey as string, {
20-
api_host: isNetlify ? '/api/ingest' : 'https://eu.posthog.com',
20+
api_host: 'https://eu.posthog.com',
2121
ui_host: 'https://eu.posthog.com',
2222
cross_subdomain_cookie: !!isProd,
2323
secure_cookie: !!isNetlify,
@@ -33,7 +33,7 @@ export default function PosthogProvider({
3333
enable_recording_console_log: false,
3434
});
3535
}
36-
}, [isDev, isNetlify, isProd, posthogProjectApiKey]);
36+
}, [isDev, isProd, posthogProjectApiKey]);
3737

3838
return <Provider client={posthog}>{children}</Provider>;
3939
}

0 commit comments

Comments
 (0)