From 78441c56682eba1d6ce9bf5f5094375068dc410c Mon Sep 17 00:00:00 2001 From: LarsLemos Date: Wed, 29 Mar 2023 19:45:04 +0200 Subject: [PATCH 1/2] Basic changes to test local config Include YAML for automated deployment, and README Include deploy script to alternate server Improve the deploy script Create docs-ci.yml (#6) Update the Main CI Improve the deploy script, fix null Key value Fix YML duplication Fix YML duplication Include config update and deployment Include config update and deployment, fix relative path Fix file tree Fix file tree, change action type Fix file tree, change action type, change wrong param Fix file tree, change action type, change wrong param, typo Add final details Change dir Change dir, fix missing clone command Include logging Update OHRI Docs user Change the hidden folder Change to copy contents Change the recursive copy Update to zip due to errors --- .github/deploy_docs.sh | 42 +++++++++++++++++++++++++++++++++++ .github/workflows/docs-ci.yml | 39 +++++++++++++++++++++++++------- README.md | 10 +++++++-- theme.config.jsx | 3 +++ 4 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 .github/deploy_docs.sh diff --git a/.github/deploy_docs.sh b/.github/deploy_docs.sh new file mode 100644 index 0000000..620664c --- /dev/null +++ b/.github/deploy_docs.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env sh + +# Rename the directory with suffix _backup_current_timestamp + +if [ -d "ohri-docs" ]; then + cd .. + mv ohri-docs ohri-docs_backup_$(date +%Y%m%d_%H%M%S) + echo "--- OHRI Backup successful ---" +else + echo "--- ohri-docs folder not found, backup not performed ---" +fi + +# Clone the repository with the reference branch named dev +git clone --branch dev https://github.com/UCSF-IGHS/ohri-docs.git + +# Navigate into the cloned directory +echo "--- Navigate into the cloned directory ---" +chown -R +cd ohri-docs +ls -la -t + +# Install dependencies and build the code +echo "--- Installing dependencies and building the code ---" +npx yarn install +npx yarn build + +ls -la -t + +# Copy the built code to the specified path on the server using scp +# scp -r ./build user@server:/usr/share/tomcat/microfrontends/ohri-docs +# scp -P 3220 -r .next ohridocs@reports.globalhealthapp.net:/usr/share/tomcat/microfrontends/ohri_docs + +echo "--- Copy Hidden folder .next to build folder to allow transfer to another server ---" +zip -r next_deploy.zip .next/ +cp -R .next/* build + +ls -la -t + +scp -P 3220 -r build ohridocs@reports.globalhealthapp.net:/usr/share/tomcat/microfrontends/ohri_docs +scp -P 3220 -r next_deploy.zip ohridocs@reports.globalhealthapp.net:/usr/share/tomcat/microfrontends/ohri_docs + +# scp -P 3220 -i /usr/local/ohridocs/.ssh/id_rsa -r .next ohridocs@reports.globalhealthapp.net:/usr/share/tomcat/microfrontends/ohri_docs diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml index 364adbc..6b1be97 100644 --- a/.github/workflows/docs-ci.yml +++ b/.github/workflows/docs-ci.yml @@ -47,21 +47,44 @@ jobs: - name: Run build run: pnpm build - docs_deployment: + update_config: runs-on: ubuntu-latest - needs: build - if: ${{ github.ref == 'refs/heads/dev' }} steps: - # Update the Microfrontends to reflect what we have in the Working branch + - name: Checkout repo to make config folder local + uses: actions/checkout@v3 + with: + ref: dev + - run: ls -la .github/ + + - name: Copy Branch Dev Import Map to remote + uses: appleboy/scp-action@v0.1.4 + with: + source: .github/deploy_docs.sh + target: /usr/share/tomcat/microfrontends/ohri-docs + host: ${{ secrets.HISTAC_HOST }} + username: ${{ secrets.HISTAC_USERNAME }} + key: ${{ secrets.HISTAC_OHRI_KEY}} + port: ${{ secrets.HISTAC_PORT }} + + docs_deployment: + runs-on: ubuntu-latest + needs: update_config + if: ${{ github.ref == 'refs/heads/main' }} + + steps: + # Update the Microfrontends to reflect what we have in the working branch + - name: Compute Timestamp + run: echo "TIMESTAMP=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - uses: garygrossgarten/github-action-ssh@release name: BackUp and Run the Update DOCS Site Script with: - command: cd /usr/share/tomcat/microfrontends/ - sh deploy-ohri-docs.sh + command: cd /usr/share/tomcat/microfrontends/ohri-docs/.github && sh deploy_docs.sh host: ${{ secrets.HISTAC_HOST }} - username: ${{ secrets.HISTAC_USERNAME }} - privateKey: ${{ secrets.HISTAC_KEY}} + username: ${{ secrets.OHRI_DOCS_USER }} + # username: ${{ secrets.HISTAC_USERNAME }} + privateKey: ${{ secrets.OHRI_DOCS_USER_KEY}} + # privateKey: ${{ secrets.HISTAC_KEY}} port: ${{ secrets.HISTAC_PORT }} diff --git a/README.md b/README.md index 5a71b2b..897a2b3 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ This documentation is intended to enable users to utilize the features of the React Form Engine (RFE) as well as OHRI associated packages. -Local Development +[**Live Demo →**](https://ohri-docs.globalhealthapp.net/) + +## Local Development To install the dependancies run: ```bash @@ -11,7 +13,11 @@ pnpm install To start the dev server on port 3000 run: ```bash -pnpm run dev +pnpm dev ``` The documentation website for the React Form Engne https://ohri-docs.globalhealthapp.net. + +## License + +MPL 2.0 diff --git a/theme.config.jsx b/theme.config.jsx index 13f137e..ed1987e 100644 --- a/theme.config.jsx +++ b/theme.config.jsx @@ -53,6 +53,9 @@ const themeConfig = { project: { link: "https://github.com/UCSF-IGHS/ohri-docs", }, + chat: { + link: "https://openmrs.slack.com/archives/C01PW9FSJBT", + }, footer: { text: © {new Date().getFullYear()} UCSF, }, From b2dd3a993f7132e44555919ed30c9a51426ff177 Mon Sep 17 00:00:00 2001 From: pirupius Date: Wed, 10 Jan 2024 12:31:12 +0300 Subject: [PATCH 2/2] updates deploy branch to main --- .github/deploy_docs.sh | 4 ++-- .github/workflows/docs-ci.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/deploy_docs.sh b/.github/deploy_docs.sh index 620664c..3ea6cac 100644 --- a/.github/deploy_docs.sh +++ b/.github/deploy_docs.sh @@ -10,8 +10,8 @@ else echo "--- ohri-docs folder not found, backup not performed ---" fi -# Clone the repository with the reference branch named dev -git clone --branch dev https://github.com/UCSF-IGHS/ohri-docs.git +# Clone the repository +git clone https://github.com/UCSF-IGHS/ohri-docs.git # Navigate into the cloned directory echo "--- Navigate into the cloned directory ---" diff --git a/.github/workflows/docs-ci.yml b/.github/workflows/docs-ci.yml index 6b1be97..ab6c0e2 100644 --- a/.github/workflows/docs-ci.yml +++ b/.github/workflows/docs-ci.yml @@ -50,16 +50,16 @@ jobs: update_config: runs-on: ubuntu-latest needs: build - if: ${{ github.ref == 'refs/heads/dev' }} + if: ${{ github.ref == 'refs/heads/main' }} steps: - name: Checkout repo to make config folder local uses: actions/checkout@v3 with: - ref: dev + ref: main - run: ls -la .github/ - - name: Copy Branch Dev Import Map to remote + - name: Copy Branch main Import Map to remote uses: appleboy/scp-action@v0.1.4 with: source: .github/deploy_docs.sh