ci: handle no-tty mode

This commit is contained in:
Glenn Y. Rolland 2021-12-21 16:39:51 +01:00
parent ef5b288261
commit 27e203a3ac
4 changed files with 96 additions and 12 deletions

View file

@ -79,16 +79,32 @@ jobs:
docker image ls -a
- name: Build HTML for docs
run: ./scripts/gx-teaching . build-docs-html
run: |
./scripts/gx-teaching \
--no-tty \
--data-dir . \
--action build-docs-html
- name: Build PDF for docs
run: ./scripts/gx-teaching . build-slides-pdf
run: |
./scripts/gx-teaching \
--no-tty \
--data-dir . \
--action build-slides-pdf
- name: Build HTML for slides
run: ./scripts/gx-teaching . build-slides-html
run: |
./scripts/gx-teaching \
--no-tty \
--data-dir . \
--action build-slides-html
- name: Build PDF for slides
run: ./scripts/gx-teaching . build-slides-pdf
run: |
./scripts/gx-teaching \
--no-tty \
--data-dir . \
--action build-slides-pdf
push-docker-image:
name: "Push docker image to registry"

View file

@ -174,13 +174,29 @@ $(BUILD_SLIDES_DIR):
## docs => static web site
##
build: build-docs build-slides ## build all documents
build: build-pdf build-html ## build all documents as PDF and HTML files
build-slides: $(SLIDES_PDF_ALL) $(SLIDES_MD_ALL) ## build PDF slides only
build-pdf: build-docs-pdf build-slides-pdf ## build all documents as PDF files
build-html: build-docs-html build-slides-html ## build all documents as HTML files
build-slides-pdf: $(SLIDES_PDF_ALL) $(SLIDES_MD_ALL) ## build PDF slides only
merge-slides: $(SLIDES_MDPP_MD) $(SLIDES_MD_ALL)
build-docs: ## build static docs site only
build-docs-pdf:
mkdir -p $(BUILD_DOCS_DIR)
rm -f $(BUILD_DOCS_DIR)/combined.pdf
PYTHONUTF8=1 \
ENABLE_PDF_EXPORT=1 \
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
pdftk \
$$(find $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \
cat output $(BUILD_DOCS_DIR)/combined.pdf
build-docs-html: ## build static docs site only
mkdir -p $(BUILD_DOCS_DIR)
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)

View file

@ -9,6 +9,11 @@ echo "Arguments: $ARGS"
EXT_UID=${EXT_UID:-999}
EXT_GID=${EXT_GID:-999}
# Create missing directories
mkdir -p _cache
mkdir -p _build
mkdir -p .marp
# Create user with given ID if needed
if ! grep -q "^[^:]*:[^:]*:$EXT_UID:" /etc/group ; then
groupadd -g "$EXT_GID" appuser
@ -20,6 +25,7 @@ if ! grep -q "^[^:]*:[^:]*:$EXT_UID:" /etc/passwd ; then
fi
if [ -d "_build" ]; then
chown -R "$EXT_UID:$EXT_GID" _cache
chown -R "$EXT_UID:$EXT_GID" _build
chown -R "$EXT_UID:$EXT_GID" .marp
fi

View file

@ -1,12 +1,58 @@
#!/bin/sh
# vim: set ft=sh:
BASEDIR="${1:-.}"
BASEDIR="$(cd "$BASEDIR" && pwd)"
ACTION="${2:-watch}"
BASEDIR="."
ACTION="watch"
DOCKER_IMAGE=glenux/teaching-boilerplate:latest
DOCKER_OPT_TTY="-t"
# Parse arguments
while [ $# -gt 0 ]; do
ARG="${1:-}"
OPT="${2:-}"
shift
echo "ARG=$ARG OPT=$OPT"
case "$ARG" in
-d|--data-dir)
shift # argument requires a parameter
if [ -z "$OPT" ]; then
>&2 echo "ERROR: missing argument for --data-dir"
exit 1
fi
if [ ! -d "$OPT" ]; then
>&2 echo "ERROR: argument for --data-dir must be a directory"
exit 1
fi
BASEDIR="$(cd "$OPT" && pwd)"
;;
-a|--action)
shift # argument requires a parameter
if [ -z "$OPT" ]; then
>&2 echo "ERROR: missing argument for --action"
exit 1
fi
ACTION="$OPT"
;;
-T|--no-tty)
DOCKER_OPT_TTY=""
;;
-h|--help)
echo "Usage: $0 [options]"
echo ""
echo "-d, --data-dir DIR Content directory"
echo "-a, --action ACTION Action (watch, build, shell, etc.)"
echo "-t, --tty Enable TTY mode (needed for shell)"
echo "-h, --help Show this help"
;;
*)
>&2 echo "ERROR: unknown option '$ARG'"
exit 1
;;
esac
done
echo "basedir = $BASEDIR"
echo "docker_image = $DOCKER_IMAGE"
@ -34,7 +80,7 @@ if [ -d "$BASEDIR/docs" ]; then
DOCKER_OPT_MKDOCS_PORT="-p 5100:5100"
fi
docker run -it \
docker run -i $DOCKER_OPT_TTY \
--shm-size=1gb \
-e "EXT_UID=$(id -u)" \
-e "EXT_GID=$(id -g)" \