From 5455eeb85bbfbc8595a0c01c20859b91c308488c Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Thu, 11 Jul 2024 09:36:11 +0930 Subject: [PATCH 1/5] Test docs deployment 1st attempt --- .github/workflows/deploy_test_docs.yml | 37 +++++++++++++++++++ .../SmartFormsRedirectToCorrectRoute.js | 22 +++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/workflows/deploy_test_docs.yml diff --git a/.github/workflows/deploy_test_docs.yml b/.github/workflows/deploy_test_docs.yml new file mode 100644 index 00000000..e9ecdb8a --- /dev/null +++ b/.github/workflows/deploy_test_docs.yml @@ -0,0 +1,37 @@ +name: Smart Forms Docs Deployment Workflow + +on: + push: + +permissions: + contents: read + pages: write + id-token: write + +jobs: + deploy-docusaurus-s3: + name: Deploy Docusaurus to S3 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + 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 static Docusaurus site to S3 + run: aws s3 sync documentation/build s3://smart-forms-test-docs/docz --cache-control no-cache diff --git a/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js b/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js index c6c5cdb7..b085e05b 100644 --- a/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js +++ b/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js @@ -103,6 +103,28 @@ function handler(event) { return request; } + + // Handle Docs routes + if (uri.includes('/docs')) { + // Reroute to smartforms.csiro.au/docs/index.html + if (uri === '/docs/') { + request.uri += 'index.html'; + return request; + } + + if (uri === '/docs') { + request.uri = '/redirect.html'; + return request; + } + + if (!uri.includes('.')) { + request.uri += '/index.html'; + return request; + } + + return request; + } + // Handle Forms Server API routes if (uri.includes('/api')) { // Remove the /api prefix From ac399e707a096f21e2d966f450da1a108dcdca02 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Thu, 11 Jul 2024 09:54:39 +0930 Subject: [PATCH 2/5] Test docs deployment 2nd attempt --- .github/workflows/deploy_app_docs.yml | 52 +++++++++++++------------- .github/workflows/deploy_test_docs.yml | 2 +- package-lock.json | 4 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/deploy_app_docs.yml b/.github/workflows/deploy_app_docs.yml index 650c5e12..fdd427da 100644 --- a/.github/workflows/deploy_app_docs.yml +++ b/.github/workflows/deploy_app_docs.yml @@ -45,32 +45,32 @@ jobs: - name: Upload static React site to S3 run: aws s3 sync apps/smart-forms-app/dist s3://smart-forms-react-app/ - deploy-docusaurus-s3: - name: Deploy Docusaurus to S3 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Use Node.js 18.x - uses: actions/setup-node@v4 - with: - 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 static Docusaurus site to S3 - run: aws s3 sync documentation/build s3://smart-forms-docs/docs +# deploy-docusaurus-s3: +# name: Deploy Docusaurus to S3 +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# +# - name: Use Node.js 18.x +# uses: actions/setup-node@v4 +# with: +# 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 static Docusaurus site to S3 +# run: aws s3 sync documentation/build s3://smart-forms-docs/docs chromatic: name: Run Chromatic diff --git a/.github/workflows/deploy_test_docs.yml b/.github/workflows/deploy_test_docs.yml index e9ecdb8a..96f0c6d3 100644 --- a/.github/workflows/deploy_test_docs.yml +++ b/.github/workflows/deploy_test_docs.yml @@ -34,4 +34,4 @@ jobs: run: npm run build -w documentation - name: Upload static Docusaurus site to S3 - run: aws s3 sync documentation/build s3://smart-forms-test-docs/docz --cache-control no-cache + run: aws s3 sync documentation/build s3://smart-forms-docs/docs --cache-control no-cache diff --git a/package-lock.json b/package-lock.json index 8a21e486..bd9c8c7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42626,7 +42626,7 @@ } }, "services/extract-express": { - "version": "0.3.0", + "version": "0.4.0", "license": "Apache-2.0", "dependencies": { "cors": "^2.8.5", @@ -42642,7 +42642,7 @@ } }, "services/populate-express": { - "version": "2.2.6", + "version": "2.2.7", "license": "Apache-2.0", "dependencies": { "@aehrc/sdc-populate": "^2.2.7", From 001a754a60573acc8c0a902b4fbe70559bdf54e5 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Thu, 11 Jul 2024 10:28:48 +0930 Subject: [PATCH 3/5] Test docs deployment 3rd attempt --- documentation/docusaurus.config.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index e4b7ea52..4f545b00 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -12,7 +12,7 @@ const config: Config = { url: 'https://smartforms.csiro.au', // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: '/docs', + baseUrl: '/docs/', // GitHub pages deployment config. // If you aren't using GitHub pages, you don't need these. @@ -20,9 +20,7 @@ const config: Config = { projectName: '', // Usually your repo name.\ onBrokenLinks: 'warn', - onBrokenMarkdownLinks: 'warn', - - trailingSlash: false, + onBrokenMarkdownLinks: 'throw', // Even if you don't use internationalization, you can use this field to set // useful metadata like html lang. For example, if your site is Chinese, you From b69a6f19e92b198bc5802d7c00fccd35ff442910 Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Thu, 11 Jul 2024 10:36:53 +0930 Subject: [PATCH 4/5] Test docs deployment 4th attempt and fix linting --- .github/workflows/deploy_app_docs.yml | 52 +++++++++++++-------------- documentation/docusaurus.config.ts | 2 ++ 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/.github/workflows/deploy_app_docs.yml b/.github/workflows/deploy_app_docs.yml index fdd427da..e355c448 100644 --- a/.github/workflows/deploy_app_docs.yml +++ b/.github/workflows/deploy_app_docs.yml @@ -45,32 +45,32 @@ jobs: - name: Upload static React site to S3 run: aws s3 sync apps/smart-forms-app/dist s3://smart-forms-react-app/ -# deploy-docusaurus-s3: -# name: Deploy Docusaurus to S3 -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# -# - name: Use Node.js 18.x -# uses: actions/setup-node@v4 -# with: -# 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 static Docusaurus site to S3 -# run: aws s3 sync documentation/build s3://smart-forms-docs/docs + # deploy-docusaurus-s3: + # name: Deploy Docusaurus to S3 + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # + # - name: Use Node.js 18.x + # uses: actions/setup-node@v4 + # with: + # 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 static Docusaurus site to S3 + # run: aws s3 sync documentation/build s3://smart-forms-docs/docs chromatic: name: Run Chromatic diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index 4f545b00..cd2ba413 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -22,6 +22,8 @@ const config: Config = { onBrokenLinks: 'warn', onBrokenMarkdownLinks: 'throw', + trailingSlash: false, + // Even if you don't use internationalization, you can use this field to set // useful metadata like html lang. For example, if your site is Chinese, you // may want to replace "en" with "zh-Hans". From fa84a345a0031998d5df78dada0d48e2be91b58e Mon Sep 17 00:00:00 2001 From: Sean Fong Date: Thu, 11 Jul 2024 11:25:32 +0930 Subject: [PATCH 5/5] CLean up github actions workflow, doc config and cloudfront redirect script --- .../{deploy_app_docs.yml => deploy_app.yml} | 27 ---------------- .../{deploy_test_docs.yml => deploy_docs.yml} | 0 .../SmartFormsRedirectToCorrectRoute.js | 31 +++++-------------- documentation/docusaurus.config.ts | 1 - 4 files changed, 8 insertions(+), 51 deletions(-) rename .github/workflows/{deploy_app_docs.yml => deploy_app.yml} (69%) rename .github/workflows/{deploy_test_docs.yml => deploy_docs.yml} (100%) diff --git a/.github/workflows/deploy_app_docs.yml b/.github/workflows/deploy_app.yml similarity index 69% rename from .github/workflows/deploy_app_docs.yml rename to .github/workflows/deploy_app.yml index e355c448..e48f9093 100644 --- a/.github/workflows/deploy_app_docs.yml +++ b/.github/workflows/deploy_app.yml @@ -45,33 +45,6 @@ jobs: - name: Upload static React site to S3 run: aws s3 sync apps/smart-forms-app/dist s3://smart-forms-react-app/ - # deploy-docusaurus-s3: - # name: Deploy Docusaurus to S3 - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v4 - # - # - name: Use Node.js 18.x - # uses: actions/setup-node@v4 - # with: - # 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 static Docusaurus site to S3 - # run: aws s3 sync documentation/build s3://smart-forms-docs/docs - chromatic: name: Run Chromatic runs-on: ubuntu-latest diff --git a/.github/workflows/deploy_test_docs.yml b/.github/workflows/deploy_docs.yml similarity index 100% rename from .github/workflows/deploy_test_docs.yml rename to .github/workflows/deploy_docs.yml diff --git a/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js b/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js index b085e05b..93db4651 100644 --- a/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js +++ b/deployment/cloudfront/SmartFormsRedirectToCorrectRoute.js @@ -82,28 +82,6 @@ function handler(event) { } - // 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; - } - - if (!uri.includes('.')) { - request.uri += '/index.html'; - return request; - } - - return request; - } - - // Handle Docs routes if (uri.includes('/docs')) { // Reroute to smartforms.csiro.au/docs/index.html @@ -118,7 +96,14 @@ function handler(event) { } if (!uri.includes('.')) { - request.uri += '/index.html'; + // For https://smartforms.csiro.au/docs/sdc/population/ cases + if (uri.endsWith('/')) { + request.uri += 'index.html'; + } + // For https://smartforms.csiro.au/docs/sdc/population cases + else { + request.uri += '/index.html'; + } return request; } diff --git a/documentation/docusaurus.config.ts b/documentation/docusaurus.config.ts index cd2ba413..bc66a853 100644 --- a/documentation/docusaurus.config.ts +++ b/documentation/docusaurus.config.ts @@ -56,7 +56,6 @@ const config: Config = { // Replace with your project's social card image: 'img/logo-sf.svg', navbar: { - title: 'Smart Forms', logo: { alt: 'Smart Forms', src: 'img/logo-sf.svg',