Skip to content

Commit

Permalink
Migrate to GitHub Pages using a Jekyll site (#24)
Browse files Browse the repository at this point in the history
* begin gh pages migration

* added more existing content

* add dependabot config

Use npm for web resources so dependabot can manage them.
Add scripts to generate latest release info and update static web resource files.

* fix web resource integrity generation

* update doc

* show current page in nav

Make page urls consistent.

* link to data life cycle pages
  • Loading branch information
cofiem authored Jul 1, 2024
1 parent d060b61 commit acd5a0a
Show file tree
Hide file tree
Showing 166 changed files with 1,453 additions and 7,702 deletions.
15 changes: 0 additions & 15 deletions .circleci/config.yml

This file was deleted.

7 changes: 0 additions & 7 deletions .docpad.cson

This file was deleted.

22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
# Updates for Gemfile, used to run GitHub Pages locally
- package-ecosystem: 'bundler'
directory: '/'
schedule:
interval: 'weekly'
# Updates for GitHub Actions, used to build and deploy GitHub Pages
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
# Updates for npm, used to provide libraries for the website
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
96 changes: 96 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
# From: https://github.com/actions/starter-workflows/blob/647cac4f347894582e3fd841b84b0b2c6485b23d/pages/jekyll-gh-pages.yml

name: Deploy website

on:
# Runs on pushes targeting the default branch
push:
branches: [$default-branch]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Generate an include file showing details for
# the latest ReDBox release.
recent-redbox-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache ReDBox latest release files
id: cache-redbox-latest-release-file
uses: actions/cache@v3
env:
cache-name: cache-redbox-latest-release-file
with:
path: |
.support/rblatest.json
_includes/latest_release.html
key: cache-redbox-latest-release-file

- if: ${{ steps.cache-redbox-latest-release-file.outputs.cache-hit != 'true' }}
name: Create latest ReDBox release details if not cached
run: .support/generate_latest_release_info.sh

static-files:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Update the static files
run: .support/update_static_files.sh

# Build and upload the GitHub Pages artifact.
build:
runs-on: ubuntu-latest
needs:
- recent-redbox-release
- static-files
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site

- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
13 changes: 8 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
out/
node_modules/
docpad-debug.log
yarn.lock
.project
_site/
.sass-cache
.jekyll-cache
.jekyll-metadata
vendor
Gemfile.lock
.idea/
node_modules/
.support/rblatest.json
22 changes: 22 additions & 0 deletions .support/generate_latest_release_info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -euo pipefail

DATA_FILE=.support/rblatest.json
HTML_FILE=_includes/latest_release.html

if [ ! -f "${DATA_FILE}" ]; then
curl --silent -L -o "${DATA_FILE}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/redbox-mint/redbox-portal/releases/latest
fi

VERSION=$(jq -r '.tag_name' "${DATA_FILE}")
URL=$(jq -r '.html_url' "${DATA_FILE}")
PUB_DATE=$(jq -r '.published_at | fromdateiso8601 | strftime("%a, %d %B %Y")' "${DATA_FILE}")

# e.g. The [most recent ReDBox version is <tag_name>](<html_url>) released on [<published_at>].
# e.g. The [most recent ReDBox version is *v3.6*](https://github.com/redbox-mint/redbox-portal/releases/tag/v3.6) released on 01 May 2024.

echo "The [most recent ReDBox version is *${VERSION}*](${URL}) released on ${PUB_DATE}." > "${HTML_FILE}"
7 changes: 7 additions & 0 deletions .support/local_jekyll_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -euo pipefail

bundle exec jekyll clean --safe --no-watch
bundle exec jekyll build --safe --no-watch
bundle exec jekyll doctor --safe
5 changes: 5 additions & 0 deletions .support/local_jekyll_server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -euo pipefail

bundle exec jekyll serve --host 0.0.0.0 --incremental --watch --safe
42 changes: 42 additions & 0 deletions .support/update_static_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -euo pipefail

npm install

# bootstrap framework
cp node_modules/bootstrap/dist/js/bootstrap.bundle.min.js static/js/bootstrap.bundle.min.js

# ref: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity#tools_for_generating_sri_hashes
BOOTSTRAP_JS_HASH=$(cat static/js/bootstrap.bundle.min.js | openssl dgst -sha512 -binary | openssl base64 -A)

cat << EOF > _includes/bootstrap_js.html
<script
src="{{ '/static/js/bootstrap.bundle.min.js' | relative_url }}"
integrity="sha512-${BOOTSTRAP_JS_HASH}">
</script>
EOF

cp node_modules/bootstrap/dist/css/bootstrap.min.css static/css/bootstrap.min.css

BOOTSTRAP_CSS_HASH=$(cat static/css/bootstrap.min.css | openssl dgst -sha512 -binary | openssl base64 -A)

cat << EOF > _includes/bootstrap_css.html
<link rel="stylesheet"
href="{{ '/static/css/bootstrap.min.css' | relative_url }}"
integrity="sha512-${BOOTSTRAP_CSS_HASH}"/>
EOF

# bootstrap icons
cp node_modules/bootstrap-icons/font/bootstrap-icons.min.css static/css/bootstrap-icons.min.css
mkdir -p static/css/fonts
cp node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff static/css/fonts/bootstrap-icons.woff
cp node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff2 static/css/fonts/bootstrap-icons.woff2

BOOTSTRAP_ICONS_HASH=$(cat static/css/bootstrap-icons.min.css | openssl dgst -sha512 -binary | openssl base64 -A)

cat << EOF > _includes/bootstrap_icons_css.html
<link rel="stylesheet"
href="{{ '/static/css/bootstrap-icons.min.css' | relative_url }}"
integrity="sha512-${BOOTSTRAP_ICONS_HASH}"/>
EOF
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

8 changes: 8 additions & 0 deletions 404.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: page_general
permalink: /404.html
title: Page not found
excerpt: The requested page could not be found.
---


1 change: 0 additions & 1 deletion CNAME

This file was deleted.

14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
source "https://rubygems.org"

# Find the current github-pages version: https://pages.github.com/versions/
gem "github-pages", "~> 231", group: :jekyll_plugins

# more recent versions of ruby do not have webrick pre-installed, so install it
gem "webrick", "~> 1.8"

# jekyll plugins are specified by the github-pages gem
group :jekyll_plugins do
gem "jekyll-feed"
gem "jekyll-redirect-from"
gem "jekyll-sitemap"
end
52 changes: 22 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,33 @@
# [Redboxresearchdata Brochure Website](https://redbox-mint.github.io/website-redboxresearchdata/)
# ReDBox Information Website

[![Build Status](https://travis-ci.org/redbox-mint/website-redboxresearchdata.svg?branch=master)](https://travis-ci.org/redbox-mint/website-redboxresearchdata)
The source code for the
[ReDBox public information website](https://redbox-mint.github.io/website-redboxresearchdata/).

## License
Creative Commons Attribution 3.0 Unported
http://creativecommons.org/licenses/by/3.0/
## Overview

Copyright (C) 2023 Queensland Cyber Infrastructure Foundation (http://www.qcif.edu.au/)
- Uses [Jekyll](https://jekyllrb.com/) and [GitHub Pages](https://docs.github.com/en/pages).
- Dependabot configured to update the Gemfile, npm packages, GitHub Actions.
- Content pages are in Markdown.
- Most recent ReDBox release info can be generated by a script, then included where ever is needed.

## Use
Download node.js (https://nodejs.org/en/download/)
## Contributing

```node --version``` (Check node.js is installed)
There are two options for contributing.

```git clone https://github.com/redbox-mint/website-redboxresearchdata.git```
### Option A

```git pull origin master``` (Once you have cloned, stay up-to-date with remote origin at github)
For simple changes - edit in the GitHub website or a local git clone and immediately deploy.

```git remote update; git show-branch master```(Check for updates)
1. Modify content that is part of the Jekyll site content.
2. Commit and push the change to the default branch.
3. The GitHub Actions will deploy the changes to the GitHub Pages site.

```cd website-redboxresearchdata```
### Option B

```npm install```
For more extensive or complicated changes - set up GitHub Pages to test changes locally.

```./node_modules/.bin/docpad run``` (Local generation and deployment of website on local server)

```./node_modules/.bin/docpad generate``` (Performs all rendering and outputs to 'out' folder. Can just use this to point your browser at index.html generated here)

```npm run deploy``` (Push changes up to github pages)

```git add --all .; git commit -m "<<Your commit message>>"; git push origin master``` (Pushes to github, which triggers our Travis CI build, which in turn deploys to github pages branch and url)

## Publishing

We use `https://surge.sh/` to publish the redbox site (apart from anything on github pages)

All of the lifting is done through package.json. So to redeploy:

- ``` npm run prodGenerate``` will create the website under ./out with links setup for production
- ``` npm run prodDeploy``` will use surge to publish the site previously generated in './out' to www.redboxresearchdata.com.au
1. Set up [rvm](https://github.com/rvm/ubuntu_rvm) on your machine or in a VM or docker container.
2. Set up the [GitHub Pages gem](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll/testing-your-github-pages-site-locally-with-jekyll).
3. Make content or structural changes.
4. Run the site locally to see that the changes are ok.
5. Commit and push the change to the default branch.
Loading

0 comments on commit acd5a0a

Please sign in to comment.