Skip to content

Commit

Permalink
CLDR-17803 docs/site: Deploy to Cloudflare
Browse files Browse the repository at this point in the history
- docs/site/* deploys to cloudflare
- PR comment tells you where to go try it
- Docker available for local test and build

Split out docs/site* from other stuff in docs/
- top level config for google sites (such as it is)
- docs/site just for the site.
  • Loading branch information
srl295 committed Aug 27, 2024
1 parent 0e8d411 commit 479850c
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 25 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@

name: Publish to gh-pages
name: gh-pages

# Note: we have a foot in two camps here, maybe more
#
# - docs/ldml is the spec, and it gets special handling and generation. Ends up cldr-smoke for now
# - docs/rfc needs to end up somewhere. for now, generate to github.io

# - docs/site is an entire 'site' that gets deployed to what will be cldr.unicode.org
# This is now handled in site.yml

permissions:
pages: write
Expand Down Expand Up @@ -57,7 +65,7 @@ jobs:
with:
ruby-version: 3.2
bundler-cache: true
- name: Build Jekyll part of the site
- name: Build Jekyll part of the site (not spec, not site/)
run: |
gem install bundler github-pages kramdown-parser-gfm # should pull in jekyll, etc.
cd docs && github-pages build && mkdir -vp ../_site/ldml
Expand Down Expand Up @@ -87,6 +95,7 @@ jobs:
rsync -cav --delete-after -e "ssh -o UserKnownHostsFile=${HOME}/.knownhosts -i ${HOME}/.key -p ${CCC_PORT}" ./_site/ ${CCC_USER}@${CCC_HOST}:spec/$(basename ${GITHUB_REF_NAME})/
echo "::endgroup::"
echo "Now go to https://cldr-smoke.unicode.org/spec/"$(basename ${GITHUB_REF_NAME})
deploy:
if: github.repository == 'unicode-org/cldr' && github.event_name == 'push'
environment:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: CLDR Site

permissions:
deployments: write
id-token: write
pull-requests: write

on:
pull_request:
paths:
- "tools/scripts/tr-archive/**"
- "docs/**"
- '.github/workflows/gh-pages.yml'
push:
branches:
- main
- "maint/maint-*"
tags:
- "release-*"
# Only run if docs change.
paths:
- "tools/scripts/tr-archive/**"
- "docs/**"
- '.github/workflows/gh-pages.yml'

jobs:
cloudflare:
runs-on: ubuntu-latest
environment: cloudflare
steps:
- uses: actions/checkout@v4
with:
lfs: false
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Setup Jekyll
run: 'gem install bundler jekyll kramdown-parser-gfm webrick'
- name: Build cldr.pages.dev
run: 'cd docs/site && jekyll build'
- name: Deploy cldr.pages.dev
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy ./_site --project-name=cldr
- name: Add deploy comment to PR
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✨ deployed to <${{ steps.deploy.outputs.deployment-url }}>'
})
23 changes: 5 additions & 18 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: CLDR LDML
title: CLDR LDML
# this config file is for NON-spec, NON-site stuff. That is, RFC and ??

name: CLDR LDML Top Matter
title: CLDR LDML Top Matter

markdown: kramdown
input: GFM
Expand All @@ -14,19 +16,4 @@ exclude:
- charts/keyboards/node_modules
- charts/keyboards/node
- ldml

#include:
# - site/

# _config.yml

# everything under 'site' should default to the 'page' layout
defaults:
- scope:
path: 'site'
values:
layout: page

collections:
site:
output: true
- site
21 changes: 21 additions & 0 deletions docs/site/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This is the config file for cldr.unicode.org

name: CLDR Site
title: CLDR Site

markdown: kramdown
input: GFM

destination: ../../_site

# Google Analytics
ga_tracking: UA-7672775-1
ga_tracking_anonymize_ip: true # Use GDPR compliant Google Analytics settings

# everything should default to the 'page' layout
defaults:
- scope:
path: ''
values:
layout: page

4 changes: 2 additions & 2 deletions docs/_layouts/page.html → docs/site/_layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<head>
<meta charset="utf-8">
<title>{{ page.title }}</title>
<link rel="stylesheet" href="/site/assets/css/reports-v2.css" />
<link rel="stylesheet" href="/site/assets/css/page.css" />
<link rel="stylesheet" href="/assets/css/reports-v2.css" />
<link rel="stylesheet" href="/assets/css/page.css" />
</head>

<body>
Expand Down
1 change: 1 addition & 0 deletions tools/scripts/web/docker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/_site
2 changes: 1 addition & 1 deletion tools/scripts/web/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FROM jekyll/jekyll
FROM jekyll/jekyll:4.2.2
RUN gem install bundler github-pages kramdown-parser-gfm webrick
8 changes: 7 additions & 1 deletion tools/scripts/web/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Previewing locally
# Docker for CLDR Site

## Previewing locally

1. install https://docker.io
2. `docker compose up`
3. visit <http://127.0.0.1:4000>
4. hit control-C to cancel the docker run.

## Building

1. `docker compose run -w /src site jekyll build`
2. output is in `./_site` here in this dir.
3 changes: 2 additions & 1 deletion tools/scripts/web/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
ports:
- 4000:4000
volumes:
- ../../../../docs:/src
- ../../../../docs/site:/src:rw
- ./_site/:/_site:rw
environment:
- PAGES_REPO_NWO=unicode-org/cldr

0 comments on commit 479850c

Please sign in to comment.