Skip to content

Commit 562be2f

Browse files
committed
ci: deploy to GitHub Pages
1 parent a303bf0 commit 562be2f

File tree

3 files changed

+57
-8
lines changed

3 files changed

+57
-8
lines changed

.github/workflows/deploy.yml

+47
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

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ import remarkKroki from 'remark-kroki-plugin';
99

1010
const isDev = process.env.NODE_ENV === 'development';
1111
const isBuildFast = isDev || !!process.env.BUILD_FAST;
12-
const isNetlify = !!process.env.NETLIFY;
13-
const isProd = isNetlify && process.env.CONTEXT === 'production';
12+
const isProd =
13+
process.env.CURRENT_BRANCH === 'main' && process.env.CONTEXT === 'production';
1414

1515
const config: Config = {
16+
organizationName: 'someengineering',
17+
projectName: 'docs.fix.security',
18+
deploymentBranch: 'gh-pages',
1619
title: 'Fix Security Documentation',
1720
url: 'https://docs.fix.security',
1821
baseUrl: '/',
@@ -25,14 +28,13 @@ const config: Config = {
2528
noIndex: !isProd,
2629
customFields: {
2730
isDev,
28-
isNetlify,
2931
isProd,
3032
posthogProjectApiKey: process.env.POSTHOG_PROJECT_API_KEY,
3133
},
3234
scripts: isProd
3335
? [
3436
{
35-
src: 'https://docs.fix.security/js/script.js',
37+
src: 'https://plausible.io/js/script.js',
3638
defer: true,
3739
'data-domain': 'docs.fix.security',
3840
},

src/providers/posthog.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ 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,
23-
secure_cookie: !!isNetlify,
23+
secure_cookie: !!isProd,
2424
debug: !!isDev,
2525
capture_pageview: false, // Page views are captured manually
2626
capture_pageleave: true,
@@ -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)