Skip to content

Commit

Permalink
Deploy documentation to s3 attempt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
fongsean committed Jul 4, 2024
1 parent be1cc98 commit c4ee0e1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 20 deletions.
25 changes: 10 additions & 15 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ name: Smart Forms Docs Deployment Workflow

on:
push:
branches: ['main']

permissions:
contents: read
pages: write
id-token: write

jobs:
deploy-docusaurus:
name: Deploy Docusaurus to GitHub Pages
environment:
name: github-pages
url: ${{ steps.build-publish.outputs.page_url }}

deploy-docusaurus-s3:
name: Deploy Docusaurus to S3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -26,20 +21,20 @@ jobs:
node-version: 18
cache: npm

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::209248795938:role/SmartFormsReactAppDeployment
aws-region: ap-southeast-2

- name: Install dependencies
run: npm ci

- name: Build documentation website
run: npm run build -w documentation

- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: documentation/build

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Upload static Storybook site to S3
run: aws s3 sync documentation/build s3://smart-forms-docs/docz

deploy-storybook:
name: Deploy Storybook to S3
Expand Down
34 changes: 33 additions & 1 deletion deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function handler(event) {

// Handle Storybook routes
if (uri.includes('/storybook')) {
// Reroute to smartforms.csiro.au/ig/index.html
// Reroute to smartforms.csiro.au/storybook/index.html
if (uri === '/storybook/') {
request.uri += 'index.html';
return request;
Expand All @@ -78,6 +78,38 @@ function handler(event) {
return request;
}


// Handle Docz routes
if(uri.includes('/docz')) {
// Reroute to smartforms.csiro.au/docz/index.html
if(uri === '/docz/') {
request.uri += 'index.html';
return request;
}

if(uri === '/docz') {
request.uri = '/redirect.html';
return request;
}

return request;
}

// Handle Docs assets and img routes
if(uri.includes('/docs')) {
// Re-route /docs/assets to /assets prefix
if (uri.startsWith('/docs/assets')) {
request.uri = uri.replace('/docs/assets', '/assets');
return request
}

// Re-route /docs/img to /img prefix
if (uri.startsWith('/docs/img')) {
request.uri = uri.replace('/docs/img', '/img');
return request
}
}

// Handle Forms Server API routes
if (uri.includes('/api')) {
// Remove the /api prefix
Expand Down
6 changes: 3 additions & 3 deletions documentation/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const config: Config = {
url: 'https://smartforms.csiro.au',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/docs',
baseUrl: '/docz',

// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'aehrc', // Usually your GitHub org/user name.
projectName: 'smart-forms', // Usually your repo name.\
organizationName: '', // Usually your GitHub org/user name.
projectName: '', // Usually your repo name.\
trailingSlash: false,

onBrokenLinks: 'warn',
Expand Down
2 changes: 1 addition & 1 deletion services/populate-express/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "populate-express",
"version": "2.2.6",
"version": "2.2.7",
"description": "",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit c4ee0e1

Please sign in to comment.