Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvt committed Mar 26, 2024
0 parents commit 1ba685b
Show file tree
Hide file tree
Showing 151 changed files with 6,488 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# start with official ruby docker image as base
FROM ruby:3.1.2

# set working directory within container
WORKDIR /usr/src/app

# pull in ruby (jekyll) and python (cite process) package info
COPY Gemfile Gemfile.lock _cite/requirements.txt ./

# install ruby packages
RUN VERSION=$(grep -A 1 'BUNDLED WITH' Gemfile.lock | tail -n 1 | xargs); \
gem install bundler --version ${VERSION} && \
bundle _${VERSION}_ install

# install python
RUN apt update && apt install -y python3 python3-pip

# install python packages
RUN python3 -m pip install --no-cache-dir --upgrade --requirement requirements.txt

# install python package for listening for file changes
RUN pip install "watchdog[watchmedo]==3.0.0"

# ports used by jekyll
EXPOSE 4000
EXPOSE 35729

# run jekyll and cite process
COPY .docker/entrypoint.sh /var
CMD [ "/var/entrypoint.sh" ]
27 changes: 27 additions & 0 deletions .docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /bin/bash

# print folder contents for debugging
echo "Contents:"
echo ""
ls
echo ""

# run cite process
python3 _cite/cite.py

# run jekyll serve in hot-reload mode
# rerun whenever _config.yaml changes (jekyll hot-reload doesn't work with this file)
watchmedo auto-restart \
--debug-force-polling \
--patterns="_config.yaml" \
--signal SIGTERM \
-- bundle exec jekyll serve --open-url --force_polling --livereload --trace --host=0.0.0.0 \
| sed "s/LiveReload address.*//g;s/0.0.0.0/localhost/g" &

# rerun cite process whenever _data files change
watchmedo shell-command \
--debug-force-polling \
--recursive \
--wait \
--command="python3 _cite/cite.py" \
--patterns="_data/sources*;_data/orcid*;_data/pubmed*;_data/google-scholar*" \
37 changes: 37 additions & 0 deletions .docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

# name of image
IMAGE=lab-website-renderer:latest

# name of running container
CONTAINER=lab-website-renderer

# choose platform flag
PLATFORM=""

# default vars
DOCKER_RUN="docker run"
WORKING_DIR=$(pwd)

# fix windows faux linux shells/tools
if [[ $OSTYPE == msys* ]] || [[ $OSTYPE == cygwin* ]]; then
DOCKER_RUN="winpty docker run"
WORKING_DIR=$(cmd //c cd)
fi

# build docker image
docker build ${PLATFORM} \
--tag ${IMAGE} \
--file ./.docker/Dockerfile . && \

# run built docker image
${DOCKER_RUN} ${PLATFORM} \
--name ${CONTAINER} \
--init \
--rm \
--interactive \
--tty \
--publish 4000:4000 \
--publish 35729:35729 \
--volume "${WORKING_DIR}:/usr/src/app" \
${IMAGE} "$@"
35 changes: 35 additions & 0 deletions .github/DISCUSSION_TEMPLATE/general.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
body:
- type: checkboxes
attributes:
label: Checks
options:
- label: I have searched **[the docs](https://greene-lab.gitbook.io/lab-website-template-docs)**, [existing issues](https://github.com/greenelab/lab-website-template/issues), and [existing discussions](https://github.com/greenelab/lab-website-template/discussions) for answers first.
required: true

- type: input
id: repo
attributes:
label: Link to your website repo
description: "In almost all cases, **we cannot help you if you don't provide this**."
placeholder: ex. https://github.com/greenelab/greenelab.com
validations:
required: true

- type: input
id: version
attributes:
label: Version of Lab Website Template you are using
description: See your `CITATION.cff` file.
placeholder: ex. 1.0.0
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: |
Describe your issue in as much detail as possible. For example: What happened? What did you expect to happen? How can we reproduce the problem? What browser are you seeing the problem in?
placeholder: Description
validations:
required: true
35 changes: 35 additions & 0 deletions .github/DISCUSSION_TEMPLATE/q-a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
body:
- type: checkboxes
attributes:
label: Checks
options:
- label: I have searched **[the docs](https://greene-lab.gitbook.io/lab-website-template-docs)**, [existing issues](https://github.com/greenelab/lab-website-template/issues), and [existing discussions](https://github.com/greenelab/lab-website-template/discussions) for answers first.
required: true

- type: input
id: repo
attributes:
label: Link to your website repo
description: "In almost all cases, **we cannot help you if you don't provide this**."
placeholder: ex. https://github.com/greenelab/greenelab.com
validations:
required: true

- type: input
id: version
attributes:
label: Version of Lab Website Template you are using
description: See your `CITATION.cff` file.
placeholder: ex. 1.0.0
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: |
Describe your issue in as much detail as possible. For example: What happened? What did you expect to happen? How can we reproduce the problem? What browser are you seeing the problem in?
placeholder: Description
validations:
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: true
contact_links:
- name: 💬 Start a discussion
url: https://github.com/greenelab/lab-website-template/discussions
about: I need help, I have a question, or other discussion.
- name: 📚 Docs issue
url: https://github.com/greenelab/lab-website-template-docs/issues
about: I have a question or issue related to the template documentation.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/issue.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 🐞 Create an issue
description: I think I've discovered a bug, I want to request a feature/change, or other issue.

body:
- type: checkboxes
attributes:
label: Checks
options:
- label: I have searched **[the docs](https://greene-lab.gitbook.io/lab-website-template-docs)**, [existing issues](https://github.com/greenelab/lab-website-template/issues), and [existing discussions](https://github.com/greenelab/lab-website-template/discussions) for answers first.
required: true

- type: input
id: repo
attributes:
label: Link to your website repo
description: "In almost all cases, **we cannot help you if you don't provide this**."
placeholder: ex. https://github.com/greenelab/greenelab.com
validations:
required: true

- type: input
id: version
attributes:
label: Version of Lab Website Template you are using
description: See your `CITATION.cff` file.
placeholder: ex. 1.0.0
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: |
Describe your issue in as much detail as possible. For example: What happened? What did you expect to happen? How can we reproduce the problem? What browser are you seeing the problem in?
placeholder: Description
validations:
required: true
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
STOP!!!

You are about to open this pull request against THE TEMPLATE ITSELF. You probably meant to open it against your own website repo.

---

FOR THE TEMPLATE MAINTAINER(S)

New template version checklist:

- [ ] I have updated CITATION and CHANGELOG as appropriate.
- [ ] I have updated lab-website-template-docs as appropriate.
- [ ] I have checked the testbed as appropriate.
4 changes: 4 additions & 0 deletions .github/user_pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This website is based on the Lab Website Template.
See its documentation for working with this site:

https://greene-lab.gitbook.io/lab-website-template-docs
58 changes: 58 additions & 0 deletions .github/workflows/build-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: build-preview
run-name: build pull request preview

on:
# run when called from another workflow
workflow_call:

# run if user manually requests it
workflow_dispatch:

# variables
env:
PREVIEWS_FOLDER: preview

permissions:
contents: write
pull-requests: write

jobs:
build-preview:
runs-on: ubuntu-latest

steps:
# for debugging
- uses: crazy-max/ghaction-dump-context@v2

- name: Checkout branch contents
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}

- name: Install Ruby packages
if: github.event.action != 'closed'
uses: ruby/[email protected]
with:
ruby-version: "3.1"
bundler-cache: true

- name: Get Pages url
if: github.event.action != 'closed'
id: pages
uses: actions/configure-pages@v4

# for debugging
- if: runner.debug == '1'
uses: mxschmitt/action-tmate@v3

- name: Build preview version of site
if: github.event.action != 'closed'
run: |
JEKYLL_ENV=production bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path || '' }}/${{ env.PREVIEWS_FOLDER }}/pr-${{ github.event.number }}"
- name: Commit preview to Pages branch
uses: rossjrw/[email protected]
with:
source-dir: _site
umbrella-dir: ${{ env.PREVIEWS_FOLDER }}
56 changes: 56 additions & 0 deletions .github/workflows/build-site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: build-site
run-name: build live site

on:
# run when called from another workflow
workflow_call:

# run if user manually requests it
workflow_dispatch:

# variables
env:
PREVIEWS_FOLDER: preview

permissions:
contents: write

jobs:
build-site:
runs-on: ubuntu-latest

steps:
# for debugging
- uses: crazy-max/ghaction-dump-context@v2

- name: Checkout branch contents
uses: actions/checkout@v4

- name: Install Ruby packages
uses: ruby/[email protected]
with:
ruby-version: "3.1"
bundler-cache: true

- name: Get Pages url
id: pages
uses: actions/configure-pages@v4

# for debugging
- if: runner.debug == '1'
uses: mxschmitt/action-tmate@v3

- name: Set root url
run: |
echo "\n\nurl: ${{ steps.pages.outputs.origin }}" >> _config.yaml
- name: Build live version of site
run: |
JEKYLL_ENV=production bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path || '' }}"
- name: Commit live site to Pages branch
uses: JamesIves/[email protected]
with:
folder: _site
clean-exclude: ${{ env.PREVIEWS_FOLDER }}
force: false
Loading

0 comments on commit 1ba685b

Please sign in to comment.