From fb86cf5d8dafce3711ac300975c389b4d99f34fc Mon Sep 17 00:00:00 2001 From: Joshua Permito Date: Mon, 11 Dec 2023 15:40:59 +0800 Subject: [PATCH] ci: publish documentation to Cloudflare Pages --- .../deployment_azure-app-service.yml | 43 +---------- .github/workflows/docs-cf-pages-publish.yml | 76 +++++++++++++++++++ 2 files changed, 79 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/docs-cf-pages-publish.yml diff --git a/.github/workflows/deployment_azure-app-service.yml b/.github/workflows/deployment_azure-app-service.yml index a907938..e040b49 100644 --- a/.github/workflows/deployment_azure-app-service.yml +++ b/.github/workflows/deployment_azure-app-service.yml @@ -5,6 +5,8 @@ name: Deploy Node.js express app to Azure Web App - compact-donuts on: push: + paths-ignore: + - 'docs/**' branches: - main - 'Sprint-[0-9]*' @@ -15,11 +17,6 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true -env: - WRS_INSTANCE: docs/ucwa - WRS_ARTIFACT: webHelpUCWA2-all.zip - WRS_DOCKER_VERSION: 232.10275 - jobs: deploy: runs-on: ubuntu-latest @@ -42,42 +39,8 @@ jobs: echo 'Install dependencies' yarn install --immutable - - name: Build jsdoc documentation - uses: andstor/jsdoc-action@v1 - with: - source_dir: . - recurse: true - output_dir: ./public/docs/jsdoc - - - name: Build Writerside docs using Docker - uses: JetBrains/writerside-github-action@v4 - with: - instance: ${{ env.WRS_INSTANCE }} - artifact: ${{ env.WRS_ARTIFACT }} - docker-version: ${{ env.WRS_DOCKER_VERSION }} - - - name: Upload Writerside documentation artifact - uses: actions/upload-artifact@v3 - with: - name: wrs_docs - path: | - artifacts/${{ env.WRS_ARTIFACT }} - artifacts/report.json - retention-days: 7 - - - name: Test Writerside documentation - uses: JetBrains/writerside-checker-action@v1 - with: - instance: ${{ env.WRS_INSTANCE }} - - - name: Unzip Writerside artifact - uses: montudor/action-zip@v1 - with: - args: unzip -qq artifacts/${{ env.WRS_ARTIFACT }} -d ./public/docs/code - - - name: Remove unused files and folders + - name: Remove docs folder from repo run: | - sudo rm -rf artifacts git rm -rf docs - name: 'Deploy to Azure Web App' diff --git a/.github/workflows/docs-cf-pages-publish.yml b/.github/workflows/docs-cf-pages-publish.yml new file mode 100644 index 0000000..8a49392 --- /dev/null +++ b/.github/workflows/docs-cf-pages-publish.yml @@ -0,0 +1,76 @@ +name: Publish Writerside and JSDoc documentation to Cloudflare Pages + +on: + push: + branches: + - main + - 'Sprint-[0-9]*' + - 'patch-[0-9]*' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + WRS_INSTANCE: docs/ucwa + WRS_ARTIFACT: webHelpUCWA2-all.zip + WRS_DOCKER_VERSION: 232.10275 + +jobs: + publish: + runs-on: ubuntu-latest + environment: + name: 'Documentation' + url: ${{ steps.deploy-to-cloudflare-pages.outputs.url }} + permissions: + contents: read + deployments: write + + name: Publish to Cloudflare Pages + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Build jsdoc documentation + uses: andstor/jsdoc-action@v1 + with: + source_dir: . + recurse: true + output_dir: ./built_docs/jsdoc + + - name: Build Writerside docs using Docker + uses: JetBrains/writerside-github-action@v4 + with: + instance: ${{ env.WRS_INSTANCE }} + artifact: ${{ env.WRS_ARTIFACT }} + docker-version: ${{ env.WRS_DOCKER_VERSION }} + + - name: Upload Writerside documentation artifact + uses: actions/upload-artifact@v3 + with: + name: wrs_docs + path: | + artifacts/${{ env.WRS_ARTIFACT }} + artifacts/report.json + retention-days: 7 + + - name: Test Writerside documentation + uses: JetBrains/writerside-checker-action@v1 + with: + instance: ${{ env.WRS_INSTANCE }} + + - name: Unzip Writerside artifact + uses: montudor/action-zip@v1 + with: + args: unzip -qq artifacts/${{ env.WRS_ARTIFACT }} -d ./built_docs/code + + - name: Publish to Cloudflare Pages + uses: cloudflare/pages-action@1 + id: deploy-to-cloudflare-pages + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} + directory: built_docs + gitHubToken: ${{ secrets.GITHUB_TOKEN }}