ammaraskar / sphinx-action

Github action that builds docs using sphinx and places errors inline
Apache License 2.0
195 stars 117 forks source link

Controlled apt #39

Open ferdnyc opened 2 years ago

ferdnyc commented 2 years ago

This PR contains changes to mitigate the issues updating / running apt in the container, as discussed in #33.

It turns out that running arbitrary scripts using os.system() works... not so well, in practice. So, this PR moves to a more controlled method of managing the container's packages, with two new with: options added to the action syntax:

- uses: ammaraskar/sphinx-action:master
  with:
    update: (true/false, defaults 'false' unless 'install' is set)
    install: >-
      a
      list
      of apt packages
      to install
    docs-folder: docs/

The added logic goes:

  1. If either 'update' or 'install' is set, update apt with
    subprocess.call(["/usr/bin/apt", "-y", "update"])
  2. Collect the list of packages from 'install'. (actions.yml doesn't take yaml sequences directly, but the funky >- syntax tells it to fold newlines into spaces and present the results as a single space-separated list.)
  3. If the list is non-empty, install them with
    subprocess.call(["/usr/bin/apt", "-y", "install", *packages])

The PR also makes two other changes:

Fixes #33 #32