Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlled apt #39

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile.pdflatex
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM sphinxdoc/sphinx-pdflatex:4.3.2

LABEL "maintainer"="Ammar Askar <[email protected]>"

ADD entrypoint.py /entrypoint.py
ADD sphinx_action /sphinx_action

ENTRYPOINT ["/entrypoint.py"]
8 changes: 8 additions & 0 deletions Dockerfile.sphinx4
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM sphinxdoc/sphinx:4.3.2

LABEL "maintainer"="Ammar Askar <[email protected]>"

ADD entrypoint.py /entrypoint.py
ADD sphinx_action /sphinx_action

ENTRYPOINT ["/entrypoint.py"]
20 changes: 19 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ inputs:
dependencies, for example with
"apt-get update -y && apt-get install -y perl"
required: false
update:
description:
Set this flag to run 'apt update' in the container before starting
the sphinx build.
required: false
default: false
install:
description:
A list of additional 'apt' packages to install before running
sphinx. (Setting this will force-enable 'update' as well.)
required: false
container:
description:
Run the build in the named container. Must be one of
'sphinx4', 'pdflatex', or 'default'.
required: false
default: 'default'
runs:
using: 'docker'
image: 'Dockerfile'
image: ${{ format('Dockerfile.{0}', inputs.container) }}

26 changes: 25 additions & 1 deletion entrypoint.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
#!/usr/bin/env python3
#!/usr/bin/env -S python3 -u
import os
import json
import subprocess
import sys
from sphinx_action import action

# This is the entrypoint called by Github when our action is run. All the
# Github specific setup is done here to make it easy to test the action code
# in isolation.


def interpret_env(env_var):
if isinstance(env_var, str):
return env_var.lower() not in ["false", "no", "off" "0"]
return bool(env_var)


if __name__ == "__main__":
print("[sphinx-action] Starting sphinx-action build.")

update = os.environ.get("INPUT_UPDATE", False)
should_update = interpret_env(update)

install = os.environ.get("INPUT_INSTALL", "")
packages = install.split()

if should_update or packages:
print("Updating apt...")
subprocess.call(["/usr/bin/apt", "-y", "update"])

print(f"{len(packages)} packages (plus dependencies) to install")
if packages:
subprocess.call(["/usr/bin/apt", "-y", "install", *packages])

if "INPUT_PRE-BUILD-COMMAND" in os.environ:
pre_command = os.environ["INPUT_PRE-BUILD-COMMAND"]
print("Running: {}".format(pre_command))
Expand Down