diff --git a/.github/workflows/docsusaurus.yml b/.github/workflows/docsusaurus.yml new file mode 100644 index 0000000000..66ec3b1e4e --- /dev/null +++ b/.github/workflows/docsusaurus.yml @@ -0,0 +1,88 @@ +name: Docs +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +on: + pull_request: + push: + branches: + - main +jobs: + Deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + src: + - 'docs/**' + - 'proto/**' + - '.github/workflows/docsusaurus.yml' + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'yarn' + cache-dependency-path: docs/yarn.lock + - name: Install Vercel CLI + run: yarn global add vercel + - name: Install Dependencies + if: steps.filter.outputs.src == 'true' + run: yarn install --frozen-lockfile + working-directory: ./docs + - uses: actions/cache@v4 + if: steps.filter.outputs.src == 'true' + with: + path: | + ${{ github.workspace }}/docs/.docusaurus + ${{ github.workspace }}/docs/node_modules/.cache + key: | + ${{ runner.os }}-docusaurus-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock', '**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} + restore-keys: | + ${{ runner.os }}-docusaurus-${{ hashFiles('**/package-lock.json', '**/npm-shrinkwrap.json', '**/yarn.lock', '**/pnpm-lock.yaml') }} + ${{ runner.os }}-docusaurus-${{ hashFiles('docs/yarn.lock') }} + - name: Prepare Preview Environment + if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }} + run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} + - name: Perpare Production Environment + if: ${{ github.ref == 'refs/heads/main' && steps.filter.outputs.src == 'true' }} + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + env: + NODE_OPTIONS: "--max_old_space_size=8192" + if: steps.filter.outputs.src == 'true' + run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Preview + if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }} + run: | + vercel deploy --prebuilt --archive=tgz --token=${{ secrets.VERCEL_TOKEN }} + echo "deploymentUrl=$(cat deployment-url.txt)" >> $GITHUB_OUTPUT + - name: Deploy Production + if: ${{ github.ref == 'refs/heads/main' && steps.filter.outputs.src == 'true'}} + run: | + vercel deploy --prebuilt --archive=tgz --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Get Preview URL + if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }} + id: myRequest + uses: fjogeleit/http-request-action@v1 + with: + url: 'https://api.vercel.com/v6/deployments?teamId=${{ secrets.VERCEL_ORG_ID }}&app=docs' + method: 'GET' + customHeaders: '{"Authorization": "Bearer ${{ secrets.VERCEL_TOKEN }}"}' + - uses: cloudposse/github-action-jq@main + if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }} + id: current + with: + compact: true + raw-output: true + input: ${{ steps.myRequest.outputs.response }} + script: |- + .deployments[] | select(.meta.githubCommitSha == "${{ github.sha }}") | .url + - uses: mshick/add-pr-comment@v2 + if: ${{ github.ref != 'refs/heads/main' && steps.filter.outputs.src == 'true' }} + with: + message: | + Your build has completed! + + [Preview deployment](https://${{ steps.current.outputs.output }}) diff --git a/.gitignore b/.gitignore index 9ccc455b50..4a8a762ef0 100644 --- a/.gitignore +++ b/.gitignore @@ -85,4 +85,5 @@ go.work.sum load-test/node_modules load-test/yarn-error.log -load-test/dist \ No newline at end of file +load-test/dist +.vercel diff --git a/docs/.gitignore b/docs/.gitignore index dd1b12666a..bd99d98c6f 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -26,3 +26,4 @@ package-lock.json npm-debug.log* yarn-debug.log* yarn-error.log* +.vercel diff --git a/docs/Dockerfile b/docs/Dockerfile deleted file mode 100644 index c7d70a964f..0000000000 --- a/docs/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -## Angular lint workspace and production build -FROM node:18 as builder -WORKDIR /docs -COPY docs/package.json docs/yarn.lock ./ -RUN yarn install --frozen-lockfile -COPY docs . -COPY proto /proto -RUN yarn build - -## Final image for serving -FROM nginx as final -COPY docs/nginx.conf /etc/nginx/nginx.conf -COPY --from=builder /docs/build /usr/share/nginx/html diff --git a/docs/babel.config.js b/docs/babel.config.js index 3e44aa2aec..279a0ff91c 100644 --- a/docs/babel.config.js +++ b/docs/babel.config.js @@ -1,4 +1,4 @@ module.exports = { presets: [require.resolve("@docusaurus/core/lib/babel/preset")], - compact: true + compact: auto }; diff --git a/docs/nginx.conf b/docs/nginx.conf deleted file mode 100644 index 7b64550084..0000000000 --- a/docs/nginx.conf +++ /dev/null @@ -1,56 +0,0 @@ -events { - worker_connections 1024; ## Default: 1024 -} - -http { - - include /etc/nginx/mime.types; - - server { - - listen 8080; - - location / { - return 301 /docs; - } - - location /docs { - alias /usr/share/nginx/html; - index /docs/index.html; - try_files $uri $uri/ /docs/index.html?q=$query_string; - } - - location = /docs/proxy/js/script.js { - proxy_pass https://plausible.io/js/script.js; - proxy_set_header Host plausible.io; - } - - location = /docs/proxy/api/event { - proxy_pass https://plausible.io/api/event; - proxy_set_header Host plausible.io; - proxy_buffering on; - proxy_http_version 1.1; - - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Host $host; - } - } - - ## enable gzip compression - gzip on; - gzip_vary on; - gzip_min_length 256; - gzip_proxied any; - - gzip_types - ## text/html is always compressed : https://nginx.org/en/docs/http/ngx_http_gzip_module.html - text/plain - text/css - text/javascript - application/javascript - application/x-javascript - application/xml - application/json - application/ld+json; -} diff --git a/docs/vercel.json b/docs/vercel.json index a36082eceb..d28b5d23ff 100644 --- a/docs/vercel.json +++ b/docs/vercel.json @@ -1,4 +1,7 @@ { + "github": { + "enabled": false + }, "cleanUrls": true, "rewrites": [ { diff --git a/docs/yarn.lock b/docs/yarn.lock index a42d5b908f..106b1b1132 100644 --- a/docs/yarn.lock +++ b/docs/yarn.lock @@ -2145,7 +2145,7 @@ "@docusaurus/theme-search-algolia" "2.2.0" "@docusaurus/types" "2.2.0" -"@docusaurus/react-loadable@5.5.2", "react-loadable@npm:@docusaurus/react-loadable@5.5.2": +"@docusaurus/react-loadable@5.5.2": version "5.5.2" resolved "https://registry.npmjs.org/@docusaurus/react-loadable/-/react-loadable-5.5.2.tgz" integrity sha512-A3dYjdBGuy0IGT+wyLIGIKLRE+sAk1iNk0f1HjNDysO7u8lhL4N3VEm+FAubmJbAztn94F7MxBTPmnixbiyFdQ== @@ -3894,9 +3894,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001464, caniuse-lite@^1.0.30001517: - version "1.0.30001538" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001538.tgz" - integrity sha512-HWJnhnID+0YMtGlzcp3T9drmBJUVDchPJ08tpUGFLs9CYlwWPH2uLgpHn8fND5pCgXVtnGS3H4QR9XLMHVNkHw== + version "1.0.30001632" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001632.tgz" + integrity sha512-udx3o7yHJfUxMLkGohMlVHCvFvWmirKh9JAH/d7WOLPetlH+LTL5cocMZ0t7oZx/mdlOWXti97xLZWc8uURRHg== ccount@^1.0.0: version "1.1.0" @@ -8546,6 +8546,14 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1: dependencies: "@babel/runtime" "^7.10.3" +"react-loadable@npm:@docusaurus/react-loadable@5.5.2": + version "5.5.2" + resolved "https://registry.npmjs.org/@docusaurus/react-loadable/-/react-loadable-5.5.2.tgz" + integrity sha512-A3dYjdBGuy0IGT+wyLIGIKLRE+sAk1iNk0f1HjNDysO7u8lhL4N3VEm+FAubmJbAztn94F7MxBTPmnixbiyFdQ== + dependencies: + "@types/react" "*" + prop-types "^15.6.2" + react-magic-dropzone@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/react-magic-dropzone/-/react-magic-dropzone-1.0.1.tgz"