Skip to content

Commit 0a2374a

Browse files
committed
Add staging deployment to docs.staging.cryptomator.org
1 parent 19dcc2d commit 0a2374a

2 files changed

Lines changed: 50 additions & 14 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy to GitHub Pages
22

33
on:
44
push:
5-
branches: ["main"]
5+
branches: ["main", "develop"]
66
workflow_dispatch:
77

88
jobs:
@@ -22,25 +22,61 @@ jobs:
2222
cache: 'npm'
2323
- name: Install dependencies
2424
run: npm ci
25-
- name: Build with Docusaurus
25+
- name: Build production
2626
run: npm run build
27-
- name: Upload artifact
27+
- name: Upload Prod Pages artifact
2828
uses: actions/upload-pages-artifact@v3
2929
with:
30+
name: prod-site
31+
path: './build'
32+
- name: Build staging
33+
run: npm run build
34+
env:
35+
SITE_URL: https://docs.staging.cryptomator.org
36+
- name: Add robots.txt for staging
37+
run: 'echo -e "User-agent: *\nDisallow: /" > build/robots.txt'
38+
- name: Upload Staging artifact
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: staging-site
3042
path: './build'
3143

32-
# DEPLOY
33-
deploy:
34-
name: Deploy to GitHub Pages
44+
# DEPLOY PROD
45+
deploy-prod:
46+
if: github.ref == 'refs/heads/main'
47+
name: Deploy Prod to GitHub Pages
3548
runs-on: ubuntu-latest
3649
needs: [build]
37-
permissions: # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
38-
pages: write # to deploy to Pages
39-
id-token: write # to verify the deployment originates from an appropriate source
50+
permissions:
51+
pages: write
52+
id-token: write
4053
steps:
4154
- name: Deploy to GitHub Pages
4255
id: deployment
43-
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
44-
environment: # Deploy to the github-pages environment
56+
uses: actions/deploy-pages@v4
57+
with:
58+
artifact_name: prod-site
59+
environment:
4560
name: github-pages
4661
url: ${{ steps.deployment.outputs.page_url }}
62+
63+
# DEPLOY STAGING
64+
deploy-staging:
65+
if: github.ref == 'refs/heads/develop'
66+
name: Deploy Staging to GitHub Pages
67+
runs-on: ubuntu-latest
68+
needs: [build]
69+
steps:
70+
- name: Download build
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: staging-site
74+
path: ./public
75+
- name: Deploy to Staging Repository
76+
uses: peaceiris/actions-gh-pages@v3
77+
with:
78+
personal_token: ${{ secrets.CRYPTOBOT_DEPLOY_STAGING_DOCS }}
79+
external_repository: cryptomator/docs-staging
80+
publish_dir: ./public
81+
publish_branch: main
82+
cname: docs.staging.cryptomator.org

docusaurus.config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const config: Config = {
1414
v4: true, // Improve compatibility with the upcoming Docusaurus v4
1515
},
1616

17-
url: 'https://docs.cryptomator.org',
17+
url: process.env.SITE_URL || 'https://docs.cryptomator.org',
1818
baseUrl: '/',
1919

2020
// GitHub pages deployment config.
@@ -62,8 +62,8 @@ const config: Config = {
6262
tagName: 'script',
6363
attributes: {
6464
src: 'https://umami.skymatic.de/script.js',
65-
'data-website-id': process.env.NODE_ENV === 'development'
66-
? 'cdd42f46-583d-4463-9ab2-8adcfe989c21' // Local development
65+
'data-website-id': process.env.NODE_ENV === 'development' || process.env.SITE_URL
66+
? 'cdd42f46-583d-4463-9ab2-8adcfe989c21' // Local development / Staging
6767
: '2df416f9-7a9c-4e58-9a45-7106f7e0a139', // Production
6868
integrity: 'sha384-6PHtXKae10+dZuA/fcmjkSTDco+NPBE5fZ4eS/Em2lVIsS6FdDZIgs06MBJLEcSW',
6969
crossorigin: 'anonymous',

0 commit comments

Comments
 (0)