From c35f8b589042de9709e28598da97cedc6c9f9dca Mon Sep 17 00:00:00 2001 From: shadowusr Date: Thu, 4 Apr 2024 00:03:08 +0300 Subject: [PATCH] chore: upload static to S3 --- .github/workflows/checks.yml | 54 ++++++++++++++++++++++++++++++++---- docusaurus.config.ts | 16 +++++------ package.json | 1 + 3 files changed, 57 insertions(+), 14 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 15ce61f..f73ade0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -28,8 +28,9 @@ jobs: - run: npm ci - run: npm test - build-storybook: + deploy-static: runs-on: ubuntu-latest + environment: CI strategy: matrix: @@ -45,9 +46,50 @@ jobs: cache: "npm" - run: npm ci - run: npm run build-storybook - - name: Save storybook static - uses: actions/upload-artifact@v4 + - run: npm run build + env: + DOCUSAURUS_URL: https://storage.yandexcloud.net + DOCUSAURUS_BASE_URL: testplane-docs/website-static/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}/ + - name: Upload storybook static + uses: jakejarvis/s3-sync-action@v0.5.1 with: - name: storybook static - path: | - storybook-static + args: --acl public-read --follow-symlinks + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_ENDPOINT: https://s3.yandexcloud.net/ + SOURCE_DIR: 'storybook-static' + DEST_DIR: 'testplane-docs/storybook-static/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}/' + - name: Upload website static + uses: jakejarvis/s3-sync-action@v0.5.1 + with: + args: --acl public-read --follow-symlinks + env: + AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_S3_ENDPOINT: https://s3.yandexcloud.net/ + SOURCE_DIR: 'build' + DEST_DIR: 'testplane-docs/website-static/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}/' + + - name: Comment PR with links to deployed static on success + if: ${{ success() }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + ### :white_check_mark: Successfully deployed static + + - [Docs website](https://storage.yandexcloud.net/testplane-ci/testplane-docs/website-static/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}/index.html) + - [Storybook](https://storage.yandexcloud.net/testplane-ci/testplane-docs/storybook-static/${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}/index.html) + comment_tag: deployment_status + + - name: Comment PR that static wasn't deployed on failure + if: ${{ failure() }} + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + ### :x: Failed to deploy static + + Please check the workflow logs for details. + comment_tag: deployment_status diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 95bf831..8c15be9 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -9,10 +9,10 @@ const config: Config = { favicon: "img/favicon.ico", // Set the production url of your site here - url: "https://testplane.example.com", + url: process.env.DOCUSAURUS_URL ?? "https://testplane.example.com", // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: "/", + baseUrl: process.env.DOCUSAURUS_BASE_URL ?? "/", // GitHub pages deployment config. organizationName: "gemini-testing", @@ -60,7 +60,7 @@ const config: Config = { position: "left", label: "Tutorial", }, - { to: "/blog", label: "Blog", position: "left" }, + { to: "#", label: "Blog", position: "left" }, { href: "https://github.com/facebook/docusaurus", label: "GitHub", @@ -76,15 +76,15 @@ const config: Config = { items: [ { label: "Configuration", - to: "/docs/config", + to: "#", }, { label: "Events", - to: "/docs/events", + to: "#", }, { label: "API reference", - to: "/docs/api", + to: "#", }, ], }, @@ -110,11 +110,11 @@ const config: Config = { }, { label: "Installation", - href: "/docs/installation", + href: "#", }, { label: "First tests with testplane", - href: "/docs/first-tests", + href: "#", }, ], }, diff --git a/package.json b/package.json index b4cff17..843a1b9 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { + "build": "docusaurus build", "start": "docusaurus start", "lint": "eslint --cache src && prettier --check .", "reformat": "eslint --cache --fix src && prettier --write .",