From 0075a55978c2e9918f1955a867b92ab10b933636 Mon Sep 17 00:00:00 2001 From: Timur Olzhabayev Date: Fri, 11 Aug 2023 15:28:29 +0200 Subject: [PATCH] prod deployment (#345) --- .../deploy-to-developer-portal-prod.yml | 48 +++++++++++++ .../docusaurus.config.devportal.prod.js | 67 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 .github/workflows/deploy-to-developer-portal-prod.yml create mode 100644 docusaurus/website/docusaurus.config.devportal.prod.js diff --git a/.github/workflows/deploy-to-developer-portal-prod.yml b/.github/workflows/deploy-to-developer-portal-prod.yml new file mode 100644 index 000000000..d816de9f0 --- /dev/null +++ b/.github/workflows/deploy-to-developer-portal-prod.yml @@ -0,0 +1,48 @@ +name: Deploy to Developer Portal PROD Bucket + +on: + push: + branches: + - main + paths: + - '.github/workflows/deploy-to-developer-portal-prod.yml' + - 'docusaurus/**' +jobs: + deploy: + name: Deploy docs to Developer Portal Bucket + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: '18' + registry-url: 'https://registry.npmjs.org' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + #mac: sed -i '' 's/title: Get started/title: Get started\nslug:\ \//g' ./docusaurus/docs/get-started/get-started.mdx + #mac: grep -rl "](/docs/" docusaurus/docs | xargs sed -i '' 's/](\/docs\//](\//g' + #linux: sed -i 's/title: Get started/title: Get started\nslug:\ \//g' ./docusaurus/docs/get-started/get-started.mdx + #linux: grep -rl "](/docs/" docusaurus/docs | xargs sed -i 's/](\/docs\//](\//g' + - name: Make docs the homepage of this subsite + run: | + rm -f ./docusaurus/website/src/pages/index.tsx + sed -i 's/title: Get started/title: Get started\nslug:\ \//g' ./docusaurus/docs/get-started/get-started.mdx + grep -rl "](/docs/" docusaurus/docs | xargs sed -i 's/](\/docs\//](\//g' + - name: Build documentation website + run: npm run docs:build -- --config docusaurus.config.devportal.prod.js + + - id: 'auth' + uses: 'google-github-actions/auth@v1' + with: + credentials_json: ${{ secrets.GCP_SA_KEY }} + - name: Deploy to Developer Portal Bucket + uses: google-github-actions/upload-cloud-storage@v1 + with: + path: './docusaurus/website/build/' + destination: 'grafana-developer-portal/plugin-tools' + parent: false diff --git a/docusaurus/website/docusaurus.config.devportal.prod.js b/docusaurus/website/docusaurus.config.devportal.prod.js new file mode 100644 index 000000000..f85b500c0 --- /dev/null +++ b/docusaurus/website/docusaurus.config.devportal.prod.js @@ -0,0 +1,67 @@ +// @ts-check +// Note: type annotations allow type checking and IDEs autocompletion + +const { + generalConfig, + plugins, + presetsDocs, + presetsTheme, + themeConfigNavbar, + themeConfigFooter, + themeConfigPrism, + themeConfigColorMode, +} = require('./docusaurus.config.base'); + + +// Replace docs link in footer so builds don't have broken links. +const [docs, ...rest] = themeConfigFooter.links; +const footerConfig = { + ...themeConfigFooter, + links: [ + { + title: 'Docs', + items: [ + { + label: 'Get Started', + to: '/', + }, + ], + }, + ...rest, + ], +}; + +/** @type {import('@docusaurus/types').Config} */ +const config = { + ...generalConfig, + url: 'https://grafana.com/', + baseUrl: 'developers/plugin-tools/', + + plugins: plugins, + + presets: [ + [ + 'classic', + /** @type {import('@docusaurus/preset-classic').Options} */ + ({ + docs: { + ...presetsDocs, + routeBasePath: '/', + }, + theme: presetsTheme, + blog: false, + }), + ], + ], + + themeConfig: + /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ + ({ + navbar: themeConfigNavbar, + footer: footerConfig, + prism: themeConfigPrism, + colorMode: themeConfigColorMode, + }), +}; + +module.exports = config;