From 479850cb88cc38348a697fe876d7436da35b6ebe Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 27 Aug 2024 14:42:40 -0500 Subject: [PATCH 1/5] CLDR-17803 docs/site: Deploy to Cloudflare - 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. --- .github/workflows/gh-pages.yml | 13 ++++- .github/workflows/site.yml | 58 +++++++++++++++++++++ docs/_config.yml | 23 ++------ docs/site/_config.yml | 21 ++++++++ docs/{ => site}/_layouts/page.html | 4 +- tools/scripts/web/docker/.gitignore | 1 + tools/scripts/web/docker/Dockerfile | 2 +- tools/scripts/web/docker/README.md | 8 ++- tools/scripts/web/docker/docker-compose.yml | 3 +- 9 files changed, 108 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/site.yml create mode 100644 docs/site/_config.yml rename docs/{ => site}/_layouts/page.html (88%) create mode 100644 tools/scripts/web/docker/.gitignore diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index aa6d0746c1d..cb9285a103e 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -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 @@ -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 @@ -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: diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml new file mode 100644 index 00000000000..3c2fe56b7d8 --- /dev/null +++ b/.github/workflows/site.yml @@ -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 }}>' + }) diff --git a/docs/_config.yml b/docs/_config.yml index 076f7760eb8..eaa4078cbb7 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -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 @@ -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 diff --git a/docs/site/_config.yml b/docs/site/_config.yml new file mode 100644 index 00000000000..ab7eabda587 --- /dev/null +++ b/docs/site/_config.yml @@ -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 + diff --git a/docs/_layouts/page.html b/docs/site/_layouts/page.html similarity index 88% rename from docs/_layouts/page.html rename to docs/site/_layouts/page.html index 875d4f5e715..adff46349b0 100644 --- a/docs/_layouts/page.html +++ b/docs/site/_layouts/page.html @@ -4,8 +4,8 @@ {{ page.title }} - - + + diff --git a/tools/scripts/web/docker/.gitignore b/tools/scripts/web/docker/.gitignore new file mode 100644 index 00000000000..0baf015229c --- /dev/null +++ b/tools/scripts/web/docker/.gitignore @@ -0,0 +1 @@ +/_site diff --git a/tools/scripts/web/docker/Dockerfile b/tools/scripts/web/docker/Dockerfile index a409613ea2d..2517642543a 100644 --- a/tools/scripts/web/docker/Dockerfile +++ b/tools/scripts/web/docker/Dockerfile @@ -1,2 +1,2 @@ -FROM jekyll/jekyll +FROM jekyll/jekyll:4.2.2 RUN gem install bundler github-pages kramdown-parser-gfm webrick diff --git a/tools/scripts/web/docker/README.md b/tools/scripts/web/docker/README.md index 029313be7d5..73d23405b86 100644 --- a/tools/scripts/web/docker/README.md +++ b/tools/scripts/web/docker/README.md @@ -1,7 +1,13 @@ -# Previewing locally +# Docker for CLDR Site + +## Previewing locally 1. install https://docker.io 2. `docker compose up` 3. visit +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. diff --git a/tools/scripts/web/docker/docker-compose.yml b/tools/scripts/web/docker/docker-compose.yml index 448241eba6f..d0a3aecb86f 100644 --- a/tools/scripts/web/docker/docker-compose.yml +++ b/tools/scripts/web/docker/docker-compose.yml @@ -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 From 20ae6fab64cef41fe641a85920f2ee37387d5e2c Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 28 Aug 2024 12:02:17 -0500 Subject: [PATCH 2/5] CLDR-17803 docs/site: add label --- .github/workflows/site.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 3c2fe56b7d8..cc1f5d8d163 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -56,3 +56,9 @@ jobs: repo: context.repo.repo, body: '✨ deployed to <${{ steps.deploy.outputs.deployment-url }}>' }) + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['Site Update'] + }) From a10c620dcf3ea18f7ca8cc708faf960da014f2f3 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 28 Aug 2024 12:07:12 -0500 Subject: [PATCH 3/5] CLDR-17803 docs/site: update label and workflow --- .github/workflows/site.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index cc1f5d8d163..9e96ac80e0f 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -8,20 +8,17 @@ permissions: on: pull_request: paths: - - "tools/scripts/tr-archive/**" - - "docs/**" - - '.github/workflows/gh-pages.yml' + # - "tools/scripts/tr-archive/**" + - "docs/site/**" + - '.github/workflows/site.yml' push: branches: - main - - "maint/maint-*" - tags: - - "release-*" # Only run if docs change. paths: - - "tools/scripts/tr-archive/**" - - "docs/**" - - '.github/workflows/gh-pages.yml' + # - "tools/scripts/tr-archive/**" + - "docs/site/**" + - '.github/workflows/site.yml' jobs: cloudflare: @@ -38,7 +35,7 @@ jobs: - name: Setup Jekyll run: 'gem install bundler jekyll kramdown-parser-gfm webrick' - name: Build cldr.pages.dev - run: 'cd docs/site && jekyll build' + run: 'cd docs/site && jekyll build && git status' - name: Deploy cldr.pages.dev id: deploy uses: cloudflare/wrangler-action@v3 From 97471c4fa3dfb446de0bd632574cdc615dcae8ce Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 28 Aug 2024 12:11:19 -0500 Subject: [PATCH 4/5] CLDR-17803 docs/site: update label and workflow --- .github/workflows/site.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 9e96ac80e0f..d14dd730a41 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -35,7 +35,7 @@ jobs: - name: Setup Jekyll run: 'gem install bundler jekyll kramdown-parser-gfm webrick' - name: Build cldr.pages.dev - run: 'cd docs/site && jekyll build && git status' + run: 'cd docs/site && jekyll build' - name: Deploy cldr.pages.dev id: deploy uses: cloudflare/wrangler-action@v3 @@ -59,3 +59,5 @@ jobs: repo: context.repo.repo, labels: ['Site Update'] }) + - name: Check for Dirty Files + run: 'git status' From e52d25daae723ff23b3caa4a1a2a34ea65eb1cf1 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Wed, 28 Aug 2024 12:20:50 -0500 Subject: [PATCH 5/5] CLDR-17803 docs/site: clean up wrangler output - pre-emptively install wrangler - see https://github.com/cloudflare/wrangler-action/issues/286 - otherwise wrangler leaves the repo a mess. --- .github/workflows/site.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index d14dd730a41..9336826c687 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -36,6 +36,9 @@ jobs: run: 'gem install bundler jekyll kramdown-parser-gfm webrick' - name: Build cldr.pages.dev run: 'cd docs/site && jekyll build' + - name: Pre-install Wrangler + run: npm i -g wrangler@3.x + # see https://github.com/cloudflare/wrangler-action/issues/286 - name: Deploy cldr.pages.dev id: deploy uses: cloudflare/wrangler-action@v3 @@ -59,5 +62,3 @@ jobs: repo: context.repo.repo, labels: ['Site Update'] }) - - name: Check for Dirty Files - run: 'git status'