Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 15 additions & 32 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,26 @@ jobs:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
path: ./repo
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Jekyll site
run: |
# GitHub-specific config
echo "url: https://${{ github.repository_owner }}.github.io" >> _config.yaml
echo "baseurl: /operating-systems" >> _config.yaml

- name: Build and push
uses: docker/build-push-action@v2
with:
context: ./repo
file: ./repo/Dockerfile
push: false
load: true
tags: operating-systems-oer/docusaurus:latest
cache-from: type=gha
cache-to: type=gha
# Build Docker image for Jekyll
docker build -t jekyll-image .

- name: Load image
run: |
mkdir output
docker image list
docker run -v $GITHUB_WORKSPACE/repo:/content -v $GITHUB_WORKSPACE/output:/output operating-systems-oer/docusaurus:latest
# Build Jekyll site
docker run --rm \
-v ${{ github.workspace }}:/usr/src/app \
jekyll-image bundle exec jekyll build

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.ACCESS_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./output
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: _site
publish_branch: gh-pages
enable_jekyll: true
2 changes: 1 addition & 1 deletion .github/workflows/os-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
contents: read

steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
Expand Down
68 changes: 33 additions & 35 deletions .github/workflows/pr-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,65 @@
name: OpenEduHub - PR Deployment

on:
workflow_dispatch:
pull_request_target:
types: [labeled]

jobs:
deploy:
if: ${{ github.event.label.name == 'needs-rendering' }}
if: ${{ github.event.label.name == 'needs-rendering' || github.event_name == 'workflow_dispatch' }}
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Set Deployment ID
run: |
# Use PR number for PR trigger and commit SHA for manual trigger
if [[ -z "${{ github.event.pull_request.number }}" ]]; then
echo "DEPLOYMENT_ID=trigger-${GITHUB_SHA::7}" >> $GITHUB_ENV
else
echo "DEPLOYMENT_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
fi
echo "DEPLOYMENT_ID=${{ env.DEPLOYMENT_ID }}"

- uses: actions/checkout@v3
with:
path: ./repo
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}

- run: |
cd repo
REF=$(echo ${{ github.event.number }} | sed 's/\//\\\//g')
sed -i "s/baseUrl: \/operating-systems\//baseUrl: \/operating-systems\/$REF\//" config.yaml

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Jekyll site
run: |
# GitHub-specific config
echo "url: https://${{ github.repository_owner }}.github.io" >> _config.yaml
echo "baseurl: /operating-systems/${{ env.DEPLOYMENT_ID }}" >> _config.yaml

- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./repo
file: ./repo/Dockerfile
push: false
load: true
tags: operating-systems/docusaurus:latest
cache-from: type=gha
cache-to: type=gha
# Build Docker image for Jekyll
docker build -t jekyll-site .

- name: Load Image
run: |
mkdir -p ${{ github.event.number }}
docker image list
docker run -v $GITHUB_WORKSPACE/repo:/content -v $GITHUB_WORKSPACE/${{ github.event.number }}:/output operating-systems/docusaurus:latest
# Build Jekyll site
docker run --rm \
-v ${{ github.workspace }}:/usr/src/app/ \
jekyll-site bundle exec jekyll build

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages-pr` branch:
publish_dir: ./${{ github.event.number }}
destination_dir: ${{ github.event.number }}
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
publish_dir: _site
destination_dir: ${{ env.DEPLOYMENT_ID }}
publish_branch: gh-pages
enable_jekyll: true

- name: Add Comment to PR
if: ${{ !startsWith(env.DEPLOYMENT_ID, 'trigger-') }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Published at https://${{ github.repository_owner }}.github.io/operating-systems/${{ github.event.number }}/
Published at https://${{ github.repository_owner }}.github.io/operating-systems/${{ env.DEPLOYMENT_ID }}/

- name: Output Deployment URL
if: ${{ startsWith(env.DEPLOYMENT_ID, 'trigger-') }}
run: |
echo "The deployment is available at https://${{ github.repository_owner }}.github.io/operating-systems/${{ env.DEPLOYMENT_ID }}/"
118 changes: 12 additions & 106 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,109 +76,15 @@ dkms.conf
# reveal-md slides output folder
_site/

# Temporary files
*.swp
*.swo
*~
slides.md

# .gif files generated with ffmpeg
*-generated.gif

# JavaScript files

# compiled output
/dist
/tmp
/out-tsc

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# IDEs and editors
.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
.sass-cache
connect.lock
typings

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Dependency directories
node_modules/
jspm_packages/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# Lerna
lerna-debug.log

# System Files
.DS_Store
Thumbs.db

# Docusaurus build files
.output/
.view/

# VSCode
.vscode/
# Builder output folder
/.output/

# Ruby files for the local Jekyll server
.sass-cache/
.jekyll-cache/
.jekyll-metadata

# Ignore folders generated by Bundler
.bundle/
vendor/
*.lock
27 changes: 10 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
FROM ghcr.io/open-education-hub/openedu-builder:0.6.1
FROM ruby:3.0-slim

# Install ffmpeg
RUN apt-get update && \
apt-get install -y ffmpeg curl make
RUN apt-get update && apt-get install -y \
build-essential \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*

# Install markdown-pp
RUN pip install MarkdownPP
WORKDIR /usr/src/app

# Install node LTS (16)
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y nodejs
COPY Gemfile ./
RUN gem install bundler:2.5.23 && bundle install

# Install reveal md
RUN npm install -g reveal-md
EXPOSE 4000

# Install docusaurus
RUN npm install [email protected]

WORKDIR /content

ENTRYPOINT ["oe_builder"]
CMD ["bundle", "exec", "jekyll", "serve", "--host", "0.0.0.0"]
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

source "https://rubygems.org"

gem 'jekyll-titles-from-headings'
gem 'jekyll-seo-tag'
gem 'jekyll-remote-theme'
gem 'github-pages', group: :jekyll_plugins
48 changes: 11 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,20 @@
REPO_NAME = operating-systems
IMAGE_NAME = $(REPO_NAME)/docusaurus:latest
CONTAINER_NAME = open-edu-hub-$(REPO_NAME)-bash
OUTPUT_DIR = $$PWD/.output/$(REPO_NAME)
IMG_NAME=$(shell basename $(CURDIR))
CONT_NAME=$(IMG_NAME)

.PHONY: all buildimg build serve run_bash enter_bash stop_bash clean cleanall

all: build

buildimg:
docker build -f ./Dockerfile --tag $(IMAGE_NAME) .

build: buildimg
@echo "Building content. This will take a while (several minutes) ..."
@echo "After the build, run"
@echo ""
@echo " make serve"
@echo ""
@mkdir -p $(OUTPUT_DIR)
docker run --rm -v $$PWD/:/content -v $(OUTPUT_DIR):/output $(IMAGE_NAME)
build:
docker build -t $(IMG_NAME) .

serve:
@echo "Point your browser to http://localhost:8080/$(REPO_NAME)"
@cd $(OUTPUT_DIR)/.. && python3 -m http.server 8080

run_bash: buildimg
@mkdir -p $(OUTPUT_DIR)
docker run -d -it --entrypoint /bin/bash --name $(CONTAINER_NAME) -v $$PWD/:/content -v $(OUTPUT_DIR):/output $(IMAGE_NAME)

enter_bash:
docker exec -it $(CONTAINER_NAME) /bin/bash

stop_bash:
-test "$(shell docker container inspect -f '{{.State.Running}}' $(CONTAINER_NAME) 2> /dev/null)" = "true" && docker stop $(CONTAINER_NAME)
docker run --rm -p 4000:4000 -v $$PWD:/usr/src/app $(IMG_NAME)

clean: stop_bash
-docker container inspect $(CONTAINER_NAME) > /dev/null 2>&1 && docker rm $(CONTAINER_NAME)
-sudo rm -fr $(OUTPUT_DIR)
stop:
@docker ps -q --filter "name=$(CONT_NAME)" | grep -q . && docker stop $(CONT_NAME) \
|| echo "No running container to stop."

cleanall: clean
-docker inspect --type=image $(IMAGE_NAME) > /dev/null 2>&1 && docker image rm $(IMAGE_NAME)
clean: stop
docker rmi $(IMG_NAME)
rm -rf _site

# Linters
.PHONY: lint typos
lint: typos

Expand Down
Loading