Skip to content

Commit

Permalink
Add S3 workflow (#362)
Browse files Browse the repository at this point in the history
This PR adds a workflow to deploy our site to production.

The workflow works by:

- Building the Jekyll site
- Downloading the library documentation files from S3 and injecting them into the Jekyll build directory
- Post-processing the S3 docs
- Deploying the site to Netlify

Additionally, it includes some additional changes to accommodate this new repository workflow. Specifically:

- adds a `.ruby-version` file to the repository
  - this file is used to ensure that the GHAs deploy workflow and the Netlify build preview environments use the same ruby version
- removes outdated references to files that used to be committed to the `api/` folder
- updates the `release_checklist.md` file to remove info about post-processing since this is handled by GHAs now
- removes any `link` directives in Jekyll that point to `api/` files since they're no longer committed to the repository and therefore cause build errors during `jekyll build`

**Note:** One of the consequences of this change is that `api/` files will not be available in Netlify deploy previews on pull requests.

Authors:
   - AJ Schmidt (https://github.com/ajschmidt8)

Approvers:
   - Ray Douglass (https://github.com/raydouglass)
  • Loading branch information
ajschmidt8 authored Apr 19, 2023
1 parent af39347 commit 37880bd
Show file tree
Hide file tree
Showing 21 changed files with 237 additions and 187 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Deploy site
on:
workflow_dispatch:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

permissions:
id-token: write
contents: read

jobs:
build:
name: Build (and deploy)
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
fetch-depth: 0

# this step uses the `.ruby-version` file
- uses: ruby/setup-ruby@v1

- name: Build Jekyll Site
run: |
bundle install
bundle exec jekyll build
- uses: aws-actions/configure-aws-credentials@v1-node16
with:
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ${{ vars.AWS_REGION }}
role-duration-seconds: 7200 # 2h

- name: Fetch doc files from S3
run: ci/download_from_s3.sh

- name: Post-process docs
run: ci/post-process.sh

- name: Deploy site
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_API_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DOCS_SITE_ID }}
run: |
npm install --global --force @aschmidt8/netlify-cli
ARGS=""
if [ "$GITHUB_REF_NAME" = "main" ]; then
ARGS="--prod"
fi
netlify deploy "$ARGS" \
--dir=_site
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.2
1 change: 0 additions & 1 deletion CNAME

This file was deleted.

18 changes: 0 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@

## Development

> **Note:** Jekyll will throw an error if you try to serve the project with symlinks enabled.
To temporarily remove symlinks, run `./update_symlinks.sh rm` from the project's root directory. Make sure not to commit the removed symlinks. Re-add them with `./update_symlinks.sh 17`, where `17` is the latest nightly version number.

### Preferred - Excluding API docs

Given the size of the API docs the following config file setup will greatly
speed up renderings:

```
bundle exec jekyll serve --config _config_ignore_api.yml
```

### Alternative - Including API docs

The folder `api/` has a lot of files and can cause the initial and subsequent
renderings to take 30 seconds or more. Running the following command will
include the API docs which can be necessary for debugging purposes:

```
bundle exec jekyll serve
```
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'
gem 'github-pages', group: :jekyll_plugins
gem "just-the-docs"
gem "just-the-docs", "= 0.3.3"

gem "webrick", "~> 1.8"
64 changes: 28 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.6.1)
activesupport (7.0.4.3)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
addressable (2.8.1)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.23.9)
concurrent-ruby (1.2.0)
dnsruby (1.61.9)
simpleidn (~> 0.1)
concurrent-ruby (1.2.2)
dnsruby (1.70.0)
simpleidn (~> 0.2.1)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
faraday (2.7.1)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
ffi (1.15.5)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (227)
github-pages (228)
github-pages-health-check (= 1.17.9)
jekyll (= 3.9.2)
jekyll (= 3.9.3)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
jekyll-commonmark-ghpages (= 0.2.0)
jekyll-commonmark-ghpages (= 0.4.0)
jekyll-default-layout (= 0.1.4)
jekyll-feed (= 0.15.1)
jekyll-gist (= 1.5.0)
Expand Down Expand Up @@ -71,7 +70,7 @@ GEM
jemoji (= 0.12.0)
kramdown (= 2.3.2)
kramdown-parser-gfm (= 1.1.0)
liquid (= 4.0.3)
liquid (= 4.0.4)
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.13.6, < 2.0)
Expand All @@ -87,13 +86,13 @@ GEM
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
i18n (0.9.5)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
jekyll (3.9.2)
jekyll (3.9.3)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 2.0)
kramdown (>= 1.17, < 3)
Expand All @@ -109,11 +108,11 @@ GEM
coffee-script-source (~> 1.11.1)
jekyll-commonmark (1.4.0)
commonmarker (~> 0.22)
jekyll-commonmark-ghpages (0.2.0)
commonmarker (~> 0.23.4)
jekyll-commonmark-ghpages (0.4.0)
commonmarker (~> 0.23.7)
jekyll (~> 3.9.0)
jekyll-commonmark (~> 1.4.0)
rouge (>= 2.0, < 4.0)
rouge (>= 2.0, < 5.0)
jekyll-default-layout (0.1.4)
jekyll (~> 3.0)
jekyll-feed (0.15.1)
Expand Down Expand Up @@ -205,29 +204,25 @@ GEM
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.3)
listen (3.7.1)
liquid (4.0.4)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
mini_portile2 (2.8.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.17.0)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
nokogiri (1.13.10-x86_64-linux)
minitest (5.18.0)
nokogiri (1.14.3-x86_64-linux)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.1)
racc (1.6.2)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
Expand All @@ -249,26 +244,23 @@ GEM
unf (~> 0.1.4)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (1.2.11)
thread_safe (~> 0.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.8.0)
webrick (1.8.1)
zeitwerk (2.6.7)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
github-pages
just-the-docs
just-the-docs (= 0.3.3)
webrick (~> 1.8)

BUNDLED WITH
2.2.17
2.4.10
5 changes: 1 addition & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ exclude:
- CONTRIBUTING.md
- README.md
- release_checklist.md
- customization/
- update_symlinks.sh
- _config_ignore_api.yml
- rm_old_docs.sh
- ci/
include:
- _sources
- _static
Expand Down
57 changes: 0 additions & 57 deletions _config_ignore_api.yml

This file was deleted.

2 changes: 1 addition & 1 deletion _data/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ apis:
versions:
# enable or disable links; 0 = disabled, 1 = enabled
legacy: 1
stable: 0
stable: 1
nightly: 0
cucim:
name: cuCIM
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
FILEPATH = sys.argv[1]

LIB_MAP_PATH = os.path.join(os.path.dirname(__file__), "lib_map.json")
RELEASES_PATH = os.path.join(os.path.dirname(__file__), "../", "_data", "releases.json")
RELEASES_PATH = os.path.join(os.path.dirname(__file__), "../", "../", "_data", "releases.json")

with open(LIB_MAP_PATH) as fp:
LIB_PATH_DICT = json.load(fp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ for FILE in $(grep "${JTD_SEARCH_TERM}\|${DOXYGEN_SEARCH_TERM}\|${PYDATA_SEARCH_
--exclude-dir=nightly \
--exclude-dir=latest \
--exclude-dir=legacy \
--exclude-dir=cudf-java \
${FOLDER_TO_CUSTOMIZE} ); do
python ${SCRIPT_SRC_FOLDER}/customize_doc.py $(realpath ${FILE})
echo "" # line break for readability
Expand Down
12 changes: 6 additions & 6 deletions customization/lib_map.sh → ci/customization/lib_map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
# "nightly": "/cuspatial/en/nightly/api.html",
# "legacy": null
# }, ...}
set -e
set -euo pipefail

SCRIPT_SRC_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" # directory where this script is located
PROJ_ROOT=$(pwd)
FOLDER_MAP="{}"

for FOLDER in api/*/ ; do
for FOLDER in _site/api/*/ ; do

LIB=$(basename ${FOLDER}) # remove api/ & trailing slash from folder
DEFAULT_PATH=${LIB}
Expand All @@ -35,14 +35,14 @@ for FOLDER in api/*/ ; do
if [ -d "${VERSION}" ]; then
DEFAULT_PATH+="/${VERSION}"

if [[ "${LIB}" =~ ^(librmm|libnvstrings)$ ]]; then
DEFAULT_PATH+="/annotated.html"
if [[ "${LIB}" = librmm ]]; then
DEFAULT_PATH+="/annotated/"

elif [ "${LIB}" = libcudf ]; then
DEFAULT_PATH+="/namespacecudf.html"
DEFAULT_PATH+="/namespacecudf/"

elif [ "${LIB}" = cudf ]; then
DEFAULT_PATH+="/index.html"
DEFAULT_PATH+="/"

elif [ -f "${VERSION}/api.html" ]; then
DEFAULT_PATH+="/api.html"
Expand Down
File renamed without changes.
Loading

0 comments on commit 37880bd

Please sign in to comment.