Skip to content

Commit d9af5cf

Browse files
committed
build the page
1 parent f8a52d8 commit d9af5cf

14 files changed

Lines changed: 523 additions & 0 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Did you remember to add a trailing slash if you added permalink frontmatter?
2+
- If you wrote a new blog post, have you added `redirect_from` in frontmatter?

.github/crush-pics/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"compression_mode": "lossless",
3+
"strip_tags": false
4+
}

.github/links-to-fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
All links are valid, nothing to see here.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
require 'uri'
2+
require 'net/http'
3+
require 'json'
4+
require 'yaml'
5+
6+
def slugify(str)
7+
str.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
8+
end
9+
10+
# Used to standardize the description format.
11+
def add_period_if_missing(string)
12+
terminal_punctuation = [".", "!", "?"].freeze
13+
string << "." unless string.end_with?(*terminal_punctuation)
14+
string
15+
end
16+
17+
# Removes Ruby symbol colons from keys (for YAML)
18+
def clear_keys(hash)
19+
hash.map do |k, v|
20+
k = k.to_s
21+
if v.is_a?(Hash)
22+
v = clear_keys(v)
23+
elsif v.is_a?(Array)
24+
v = v.map do |item|
25+
i = clear_keys(item) if item.is_a?(Hash)
26+
i
27+
end
28+
end
29+
30+
[k, v]
31+
end.to_h
32+
end
33+
34+
# Check for ENV vars
35+
["NOTION_TOKEN", "NOTION_DB_ID", "TARGET_PATH"].each do |v|
36+
raise "Need to provide #{v} as an environment variable for this to work." if ENV[v].nil?
37+
end
38+
39+
# Preps the request
40+
uri = URI("https://api.notion.com/v1/databases/#{ENV['NOTION_DB_ID']}/query")
41+
http = Net::HTTP.new(uri.host, uri.port)
42+
http.use_ssl = true
43+
44+
request = Net::HTTP::Post.new(uri.request_uri)
45+
request["Authorization"] = "Bearer #{ENV['NOTION_TOKEN']}"
46+
request["Notion-Version"] = "2022-06-28"
47+
request["Accept"] = "application/json"
48+
request["Content-Type "] = "application/json"
49+
response = http.request(request)
50+
51+
# If it's not a failure
52+
if response.is_a?(Net::HTTPSuccess)
53+
puts "Roadmap data loaded. Processing..."
54+
55+
# Parses the response
56+
content = JSON.parse(response.body)
57+
58+
# Preps the object to be serialized later
59+
output = {
60+
:now => [],
61+
:soon => [],
62+
:later => []
63+
}
64+
65+
# Maps each row to a column, with properly transformed properties
66+
content["results"].each do |row|
67+
group = nil
68+
entry = {}
69+
70+
row["properties"].each_pair do |name, val|
71+
case name
72+
when "Status" then group = slugify(row["properties"]["Status"]["select"]["name"]).to_sym # Target for later
73+
when "Title" then entry[:title] = val["title"][0]["text"]["content"]
74+
when "Description" then entry[:description] = add_period_if_missing(val["rich_text"][0]["text"]["content"]) unless val["rich_text"].empty?
75+
when "Release" then entry[:release] = val["select"]["name"] unless val["select"].empty?
76+
when "Paid" then entry[:paid] = val["checkbox"]
77+
end
78+
end
79+
80+
output[group] = [] if output[group].nil?
81+
output[group] << entry
82+
end
83+
84+
# Only select the statuses we need for the roadmap
85+
output.select! { |key, _| [:now, :soon, :later].include?(key) }
86+
87+
# Sort by paid, then alphabetically by title
88+
[:now, :soon, :later].each do |group|
89+
output[group].sort_by! { |entry| [entry[:paid] ? 0 : 1, entry[:title]] }
90+
end
91+
92+
# Add one-by-two class to now, soon, and later
93+
[:now, :soon, :later].each do |group|
94+
# The `one-by-two` class is used to style these two sections
95+
output[group].each do |entry|
96+
entry[:class] = "one-by-two"
97+
end
98+
end
99+
100+
# Emtpy the target file and write the serialized YAML to it
101+
output = clear_keys(output)
102+
File.open(ENV['TARGET_PATH'], 'w') do |file|
103+
file.truncate 0
104+
file.write output.to_yaml
105+
end
106+
107+
# Call it a day
108+
puts "Roadmap data written to #{ENV['TARGET_PATH']}."
109+
else
110+
# This should prevent a broken roadmap version to be checked in
111+
raise "Could not get database from Notion"
112+
end

.github/stale.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# For now we want to only check for stale pull requests
2+
only: pulls
3+
4+
# Number of days of inactivity before an issue becomes stale
5+
daysUntilStale: 60
6+
7+
# Number of days of inactivity before a stale issue is closed
8+
daysUntilClose: 7
9+
10+
# Issues with these labels will never be considered stale
11+
exemptLabels:
12+
- pinned
13+
- security
14+
# Comment to post when marking an issue as stale. Set to `false` to disable
15+
markComment: >
16+
This issue was automatically marked as stale due to a lack of recent activity.
17+
If you'd like to revive it, please comment or update as requested!
18+
19+
# Comment to post when closing a stale issue. Set to `false` to disable
20+
closeComment: false

.github/workflows/cd-jekyll.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Deploy Jekyll site to Pages
2+
3+
on:
4+
push:
5+
branches: ["master", "transfering_old_docs_site"] # run it from this branch, for faster iteration
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
permissions:
11+
contents: read
12+
pages: write
13+
id-token: write
14+
15+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
16+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
17+
concurrency:
18+
group: "pages"
19+
cancel-in-progress: false
20+
21+
jobs:
22+
# Build job
23+
build:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- name: Setup Ruby # uses version from .ruby-version
29+
uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1.179.0
30+
with:
31+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
32+
cache-version: 0 # Increment this number if you need to re-download cached gems
33+
- name: Setup Pages
34+
id: pages
35+
uses: actions/configure-pages@v5
36+
- name: Build with Jekyll
37+
# Outputs to the './_site' directory by default
38+
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
39+
env:
40+
JEKYLL_ENV: production
41+
- name: Setup Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: '18'
45+
- name: Install Minifiers
46+
run: npm install -g uglify-js csso-cli
47+
- name: Minify JavaScript
48+
run: |
49+
find _site -name "*.js" -exec uglifyjs --compress --mangle -o {} -- {} \;
50+
- name: Minify CSS
51+
run: |
52+
find _site -name "*.css" -exec csso --input {} --output {} \;
53+
- name: Upload artifact
54+
# Automatically uploads an artifact from the './_site' directory by default
55+
uses: actions/upload-pages-artifact@v3
56+
57+
# Deployment job
58+
deploy:
59+
environment:
60+
name: github-pages
61+
url: ${{ steps.deployment.outputs.page_url }}
62+
runs-on: ubuntu-latest
63+
needs: build
64+
steps:
65+
- name: Deploy to GitHub Pages
66+
id: deployment
67+
uses: actions/deploy-pages@v4
68+

.github/workflows/ci-jekyll.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Jekyll site CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
# `refresh-docs.yml` cannot trigger workflows with its `GITHUB_TOKEN` except through an explicit `workflow_dispatch`
11+
# (cf. https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow):
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-22.04
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Set up Ruby # uses version from .ruby-version
25+
uses: ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
26+
with:
27+
bundler-cache: true
28+
29+
- name: Install dependencies
30+
run: bundle install
31+
32+
- name: Setup Node
33+
uses: actions/setup-node@v2
34+
with:
35+
node-version: 14
36+
cache: "yarn"
37+
38+
- name: Install packages
39+
run: yarn
40+
41+
- name: "Lint markdown"
42+
run: "yarn lint-markdown"
43+
44+
- name: "Lint styles"
45+
run: "yarn lint-styles"
46+
47+
- name: "Validate links"
48+
run: "yarn lint-links"
49+
50+
- name: "Lint scripts"
51+
run: "yarn lint-scripts"
52+
53+
- name: Build Jekyll Site
54+
env:
55+
JEKYLL_ENV: staging
56+
NODE_ENV: production
57+
run: "script/build"
58+
59+
- name: "Check all links"
60+
run: "script/links"

.github/workflows/crush-pics.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Crush images
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
paths:
7+
- '**.jpg'
8+
- '**.jpeg'
9+
- '**.png'
10+
- '**.gif'
11+
# jobs:
12+
# crush:
13+
# runs-on: ubuntu-22.04
14+
# steps:
15+
# - name: Checkout
16+
# uses: actions/checkout@v2
17+
# - name: Crush images
18+
# uses: crush-pics/crush-pics-github-action@master
19+
# with:
20+
# repo-token: ${{ secrets.GITHUB_TOKEN }}
21+
# api-key: ${{ secrets.CRUSH_PICS_API_KEY }}

.github/workflows/links.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Links
2+
3+
on:
4+
repository_dispatch:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: "0 0 * * 0"
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Ruby # uses version from .ruby-version
16+
uses: ruby/setup-ruby@d5fb7a202fc07872cb44f00ba8e6197b70cb0c55 # v1.179.0
17+
with:
18+
bundler-cache: true
19+
20+
- name: Install dependencies
21+
run: bundle install
22+
23+
- name: Build Jekyll Site
24+
env:
25+
JEKYLL_ENV: staging
26+
run: "script/build"
27+
28+
- name: "Check all links"
29+
id: htmlproofer
30+
run: "script/links > ./.github/links-to-fix.md"
31+
32+
- name: Create Issue From File
33+
if: steps.htmlproofer.outputs.exit_code != 0
34+
uses: peter-evans/create-issue-from-file@v5
35+
with:
36+
title: Link Checker Report
37+
content-filepath: ./.github/links-to-fix.md
38+
assignees: jeff-bruemmer
39+

.github/workflows/refresh-docs.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Refresh docs"
2+
on:
3+
schedule:
4+
- cron: "0 0 * * 1-5"
5+
# Run every hour so we can test properly
6+
# - cron: "0 */1 * * 1-5"
7+
8+
jobs:
9+
update-latest-and-master-docs:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Install dependencies
14+
run: yarn install --frozen-lockfile --prefer-offline
15+
- name: Update docs
16+
run: |
17+
./script/docs-update
18+
./script/docs master --set-version master
19+
- name: Create a pull request
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: |
23+
if git diff --quiet ; then
24+
echo "No changes to commit."
25+
else
26+
git config user.email "metabase-bot@metabase.com"
27+
git config user.name "Metabase Docs bot"
28+
update_branch="docs-update-${{ github.run_number }}"
29+
git switch --create "${update_branch}"
30+
git add .
31+
git commit \
32+
--author="Metabase Docs bot <metabase-bot@metabase.com>" \
33+
--message="Update master and latest docs"
34+
git push --force -u origin "${update_branch}"
35+
gh pr create --title "Refresh docs (nightly)" --body ""
36+
# `GITHUB_TOKEN` cannot trigger workflows except through an explicit `workflow_dispatch`
37+
# (cf. https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow),
38+
# thus creating the pull request above does not cause any workflow to run.
39+
# Trigger the workflow manually:
40+
gh workflow run --ref "${update_branch}" ci-jekyll.yml
41+
fi

0 commit comments

Comments
 (0)