Skip to content

Commit 010a630

Browse files
committed
Add .github _except cd-jekyll_
1 parent a7f4803 commit 010a630

File tree

13 files changed

+455
-0
lines changed

13 files changed

+455
-0
lines changed

.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/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 "[email protected]"
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 <[email protected]>" \
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
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Refresh Roadmap
2+
on:
3+
workflow_dispatch: # Deliberately left empty. Allows us to trigger the workflow manually.
4+
jobs:
5+
refresh-roadmap:
6+
runs-on: ubuntu-22.04
7+
steps:
8+
- name: Checkout # To make sure there's something for the action to work off of
9+
uses: actions/checkout@master
10+
with:
11+
ref: ${{ github.ref }}
12+
- name: Set up Ruby
13+
uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
14+
with:
15+
ruby-version: 2.7.2
16+
- name: Pull Roadmap
17+
env:
18+
NOTION_TOKEN: secret_tmp642IVFKbv3oSlmD2SJ6tSno0MtEgRbmw6KgO4rE7
19+
NOTION_DB_ID: bca1384db53d4205bf1d99fc93f2151a
20+
TARGET_PATH: ./_data/roadmap.yml
21+
run: ruby -r ./.github/refresh-roadmap/refresh-roadmap.rb
22+
timeout-minutes: 2
23+
- name: Commit changes # Otherwise this just changes in some machine in the cloud
24+
run: |
25+
git config --local user.name "${{ github.actor }}"
26+
git add ./_data/roadmap.yml
27+
git commit -m "Refreshing the roadmap data file"
28+
- name: Push changes # push the output folder to your repo
29+
uses: ad-m/github-push-action@master
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
branch: ${{ github.ref }}
33+
force: false

0 commit comments

Comments
 (0)