Skip to content

Commit

Permalink
Moving to rsync (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
tolzhabayev authored Oct 15, 2024
1 parent 5fecdbf commit ca524fc
Show file tree
Hide file tree
Showing 22 changed files with 5,249 additions and 3,527 deletions.
28 changes: 9 additions & 19 deletions .github/workflows/deploy-to-dev-portal-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,18 @@ jobs:

- name: Install dependencies
uses: ./.github/actions/yarn-nm-install

#mac: sed -i '' 's/title: Set up Scenes/title: Set up Scenes\nslug:\ \//g' ./docusaurus/docs/getting-started.md
#linux: sed -i 's/title: Set up Scenes/title: Set up Scenes\nslug:\ \//g' ./docusaurus/docs/getting-started.md
- name: Make docs the homepage of this subsite
run: |
rm -f ./docusaurus/website/src/pages/index.tsx
sed -i 's/title: Set up Scenes/title: Set up Scenes\nslug:\ \//g' ./docusaurus/docs/getting-started.md

- name: Build documentation website
env:
GTAG_CONTAINER_ID: ${{ secrets.GTAG_CONTAINER_ID }}
run: |
cd ./docusaurus/website
yarn docs:build --config docusaurus.config.devportal.js
run: yarn docs:build:dev

- id: 'auth'
uses: 'google-github-actions/auth@v1'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GCP_SA_KEY_DEV }}
- name: Deploy to Developer Portal Bucket
uses: google-github-actions/upload-cloud-storage@v1
with:
path: './docusaurus/website/build/'
destination: 'staging-developer-portal/scenes'
parent: false

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

- name: 'Deploy to Developer Portal Bucket'
run: |
gsutil -m rsync -r -d -c ./docusaurus/website/build/ gs://staging-developer-portal/scenes
30 changes: 10 additions & 20 deletions .github/workflows/deploy-to-dev-portal-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,18 @@ jobs:

- name: Install dependencies
uses: ./.github/actions/yarn-nm-install

#mac: sed -i '' 's/title: Set up Scenes/title: Set up Scenes\nslug:\ \//g' ./docusaurus/docs/getting-started.md
#linux: sed -i 's/title: Set up Scenes/title: Set up Scenes\nslug:\ \//g' ./docusaurus/docs/getting-started.md
- name: Make docs the homepage of this subsite
run: |
rm -f ./docusaurus/website/src/pages/index.tsx
sed -i 's/title: Set up Scenes/title: Set up Scenes\nslug:\ \//g' ./docusaurus/docs/getting-started.md

- name: Build documentation website
env:
GTAG_CONTAINER_ID: ${{ secrets.GTAG_CONTAINER_ID }}
run: |
cd ./docusaurus/website
yarn build --config docusaurus.config.devportal.prod.js
run: yarn docs:build

- id: 'auth'
uses: 'google-github-actions/auth@v1'
uses: 'google-github-actions/auth@v2'
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/scenes'
parent: false

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'

- name: 'Deploy to Developer Portal Bucket'
run: |
gsutil -m rsync -r -d -c ./docusaurus/website/build/ gs://grafana-developer-portal/scenes
44 changes: 44 additions & 0 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test docs build

on:
pull_request:
branches:
- main

jobs:
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
docs: ${{ steps.filter.outputs.docs }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
docs:
- '.github/workflows/deploy-to-developer-portal-dev.yml'
- '.github/workflows/deploy-to-developer-portal-prod.yml'
- '.github/workflows/test-build.yml'
- 'docusaurus/**'
- 'package-lock.json'
build-docs:
needs: changes
if: ${{ needs.changes.outputs.docs == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
cache: 'yarn'
- name: Install dependencies
uses: ./.github/actions/yarn-nm-install

- name: Build documentation website (Dev Portal)
run: yarn docs:build
4 changes: 2 additions & 2 deletions docusaurus/docs/advanced-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ The preceding code will render a scene with a template variable, text input, and
You can register a custom variable macro using `sceneUtils.registerVariableMacro`. A variable macro is useful for variable expressions you want to be evaluted dynamically based on some context. Examples of core variables
that are implemented as macros.

- ${\_\_url.params:include:var-from,var-to}
- ${\_\_user.login}
- `${__url.params:include:var-from,var-to}`
- `${__user.login}`

Example:

Expand Down
1 change: 1 addition & 0 deletions docusaurus/docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
id: getting-started
title: Set up Scenes
slug: /
---

This topic describes how to install Scenes and create your first "Hello World" scene.
Expand Down
146 changes: 146 additions & 0 deletions docusaurus/website/docusaurus.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
const path = require('path');
const prism = require('prism-react-renderer');

const {
themes: { oneDark },
} = prism;

// Replace background and color to better match Grafana theme.
const grafanaPrismTheme = {
...oneDark,
plain: {
color: 'rgb(204, 204, 220)',
backgroundColor: '#181b1f',
},
};

const customFields = {
nodeEnv: process.env.NODE_ENV,
};

/** @type {import('@docusaurus/types').Config} */
const generalConfig = {
title: 'Grafana Scenes',
tagline: 'Build highly interactive Grafana apps with ease.',
baseUrl: 'scenes/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.png',
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'grafana', // Usually your GitHub org/user name.
projectName: 'scenes', // Usually your repo name.

// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
};

const plugins = [
[
'docusaurus-lunr-search',
{
disableVersioning: true,
},
],
];

const presetsDocs = {
path: '../docs',
sidebarPath: require.resolve('./sidebars.js'),
// Please change this to your repo.
// Remove this to remove the "edit this page" links.
editUrl: 'https://github.com/grafana/scenes/edit/main/docusaurus/website',
};

const presetsTheme = {
customCss: require.resolve('./src/css/custom.css'),
};

const themeConfigNavbar = {
title: 'Grafana Scenes',
logo: {
alt: 'Grafana Logo',
src: 'img/logo.svg',
},
items: [
{ href: 'https://community.grafana.com/c/support/scenes/85', label: 'Help', position: 'right' },
{
href: 'https://www.github.com/grafana/scenes',
label: 'GitHub',
position: 'right',
},
],
};

const themeConfigFooter = {
style: 'dark',
links: [
{
title: 'Docs',
items: [
{
label: 'Get Started',
to: '/',
},
],
},
{
title: 'Community',
items: [
{
label: 'Github Issues',
href: 'https://www.github.com/grafana/scenes/issues',
},
{
label: 'Grafana Community Forums',
href: 'https://community.grafana.com/c/support/scenes/85',
},
],
},
{
title: 'Social',
items: [
{
label: 'GitHub',
href: 'https://www.github.com/grafana/scenes',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} Grafana Labs. Built with Docusaurus.`,
};

const themeConfigPrism = {
theme: grafanaPrismTheme,
additionalLanguages: ['bash', 'diff', 'json'],
magicComments: [
{
className: 'code-block-addition-highlighted-line',
line: 'addition-highlight-next-line',
block: { start: 'addition-highlight-start', end: 'addition-highlight-end' },
},
],
};

const themeConfigColorMode = {
defaultMode: 'dark',
disableSwitch: true,
respectPrefersColorScheme: false,
};

module.exports = {
customFields,
generalConfig,
plugins,
presetsDocs,
presetsTheme,
themeConfigNavbar,
themeConfigFooter,
themeConfigPrism,
themeConfigColorMode,
};
71 changes: 71 additions & 0 deletions docusaurus/website/docusaurus.config.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const {
generalConfig,
plugins,
presetsDocs,
presetsTheme,
themeConfigNavbar,
themeConfigFooter,
themeConfigPrism,
themeConfigColorMode,
} = require('./docusaurus.config.base');

const devPortalHome = 'https://grafana-dev.com/developers';
const [docsFooterLinks, ...otherFooterLinks] = themeConfigFooter.links;

/** @type {import('@docusaurus/types').Config} */
const config = {
...generalConfig,
url: 'https://grafana-dev.com/',
baseUrl: 'developers/scenes/',
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,
items: [
{ href: devPortalHome, label: 'Portal Home', position: 'right', target: '_self' },
...themeConfigNavbar.items,
],
},
footer: {
...themeConfigFooter,
links: [
{
...docsFooterLinks,
items: [
...docsFooterLinks.items,
{
label: 'Portal Home',
href: devPortalHome,
target: '_self',
},
],
},
...otherFooterLinks,
],
},
prism: themeConfigPrism,
colorMode: themeConfigColorMode,
}),
};

module.exports = config;
Loading

0 comments on commit ca524fc

Please sign in to comment.