generated from greenelab/lab-website-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dd784fa
Showing
148 changed files
with
6,084 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
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: "**Strongly recommended** so we can help troubleshoot your issue." | ||
placeholder: ex. https://github.com/greenelab/greenelab.com | ||
|
||
- 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 | ||
|
||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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 | ||
- name: Print contexts | ||
uses: crazy-max/ghaction-dump-context@v1 | ||
|
||
- name: Checkout branch contents | ||
uses: actions/checkout@v3 | ||
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/setup-ruby@v1 | ||
with: | ||
ruby-version: "3.0" | ||
bundler-cache: true | ||
|
||
- name: Get Pages url | ||
if: github.event.action != 'closed' | ||
id: pages | ||
uses: actions/configure-pages@v2 | ||
with: | ||
enablement: false | ||
|
||
- 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/pr-preview-action@v1 | ||
with: | ||
source-dir: _site | ||
umbrella-dir: ${{ env.PREVIEWS_FOLDER }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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 | ||
- name: Print contexts | ||
uses: crazy-max/ghaction-dump-context@v1 | ||
|
||
- name: Checkout branch contents | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Ruby packages | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: "3.0" | ||
bundler-cache: true | ||
|
||
- name: Get Pages url | ||
id: pages | ||
uses: actions/configure-pages@v2 | ||
with: | ||
enablement: false | ||
|
||
- 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/github-pages-deploy-action@v4 | ||
with: | ||
folder: _site | ||
clean-exclude: ${{ env.PREVIEWS_FOLDER }} | ||
force: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
name: first-time-setup | ||
run-name: first time setup of repo | ||
|
||
on: | ||
# run if user manually requests it | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
first-time-setup: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# for debugging | ||
- name: Print contexts | ||
uses: crazy-max/ghaction-dump-context@v1 | ||
|
||
- name: Create Pages branch | ||
uses: peterjgrainger/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
branch: "gh-pages" | ||
|
||
- name: Checkout Pages branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: gh-pages | ||
|
||
# clean slate, as if starting from orphan branch | ||
- name: Clear Pages branch | ||
run: rm -rf * .github .docker .gitignore | ||
|
||
# prevent GitHub from running Jekyll a second time after build | ||
- name: Make .nojekyll file | ||
run: touch .nojekyll | ||
|
||
- name: Make placeholder homepage | ||
run: echo "Placeholder homepage" > index.html | ||
|
||
- name: Commit changes to Pages branch | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: gh-pages | ||
commit_message: "Clear branch" | ||
|
||
- name: Checkout main branch | ||
uses: actions/checkout@v3 | ||
|
||
- name: Remove files user doesn't need | ||
run: | | ||
rm -rf \ | ||
CHANGELOG.md \ | ||
testbed.md \ | ||
.github/ISSUE_TEMPLATE \ | ||
.github/workflows/versioning.yaml \ | ||
.github/pull_request_template.md \ | ||
- name: Rename files | ||
run: | | ||
mv .github/user_pull_request_template.md .github/pull_request_template.md | ||
- name: Set vars for personalization | ||
run: | | ||
user="${{ github.repository_owner }}" | ||
description="An engaging 1-3 sentence description of your lab." | ||
echo "USER=${user}" >> $GITHUB_ENV | ||
echo "DESCRIPTION=${description}" >> $GITHUB_ENV | ||
- name: Personalize readme for user | ||
run: | | ||
echo " | ||
# ${{ env.USER }}'s Website | ||
Visit **[website url](#)** 🚀 | ||
_Built with [Lab Website Template](https://greene-lab.gitbook.io/lab-website-template-docs)_ | ||
" > README.md | ||
- name: Personalize Jekyll config for user | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { readFileSync, writeFileSync } = require("fs"); | ||
const file = "_config.yaml"; | ||
const contents = readFileSync(file) | ||
.toString() | ||
.replace(/(^title: ).*$/m, "$1${{ env.USER }}") | ||
.replace(/(^subtitle: ).*$/m, "$1") | ||
.replace(/(^description: ).*$/m, "$1${{ env.DESCRIPTION }}") | ||
.replace(/(^ email: ).*$/m, "$1contact@${{ env.USER }}.com") | ||
.replace(/(^ github: ).*$/m, "$1${{ env.USER }}") | ||
.replace(/(^ twitter: ).*$/m, "$1${{ env.USER }}") | ||
.replace(/(^ youtube: ).*$/m, "$1${{ env.USER }}"); | ||
writeFileSync(file, contents); | ||
- name: Personalize homepage for user | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { readFileSync, writeFileSync } = require("fs"); | ||
const file = "index.md"; | ||
let contents = readFileSync(file).toString(); | ||
const find = /\# Lab Website Template[\s\S]+({% include section\.html)/; | ||
const replace = `# ${{ env.USER }}'s Website\n\n${{ env.DESCRIPTION }}\n\n$1`; | ||
contents = contents.replace(find, replace); | ||
writeFileSync(file, contents); | ||
- name: Commit changed files | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "Setup repo" |
Oops, something went wrong.