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

Run pandoc command in a shell? #21

Open
kwsp opened this issue Sep 13, 2021 · 3 comments
Open

Run pandoc command in a shell? #21

kwsp opened this issue Sep 13, 2021 · 3 comments
Labels
question Further information is requested

Comments

@kwsp
Copy link

kwsp commented Sep 13, 2021

Would it be possible to call the pandoc command from a shell? I have a build script written in python that calls pandoc over some files through the subprocess module.

@alerque
Copy link
Collaborator

alerque commented Sep 13, 2021

To do that via docker-run steps in an actions workflow you would either need to install Python into the Pandoc image or Pandoc into some image of your own. Personally I'd suggest a 3rd route of just making your own image with your own tools and using that as your runner.

For example you could do this with Nix:

shell.nix: (in your project's root)

with import <nixpkgs> {};
mkShell {
  nativeBuildInputs = [ python pandoc ];
}

.github/workflow/build.yml: (step)

- name: Run builder in nix
  uses: docker://nixos/nix
  run: |
    nix-shell --run ./build.py

Similar things could be done with almost any Linux distro base image of your choice (that happens to have Pandoc and Python packages).

@alerque alerque added the question Further information is requested label Sep 13, 2021
@kwsp
Copy link
Author

kwsp commented Sep 15, 2021

I found a better way to do this. Github Action actually lets you run jobs inside docker containers, rather simply using the entrypoint's of a given container (which is currently the only version specified in the README). This is done by specifying the container value of a job. For example,

name: Build
on: push

jobs:
  convert_via_pandoc:
    runs-on: ubuntu-20.04
    container: 
      image: pandoc/core:2.9

    steps:
      - uses: actions/checkout@v2
 
      - run: pandoc README.md -o README.html

This way, it's a lot easier to build custom images with custom dependencies, specifying the container value, then having access to all those executables in your PATH in the rest of the job script. For example, I built a custom image that adds the python3 dependency: tigernie/pandoc-python3,

Should we add this to the README for when people come to this repo from search with this use case in mind?

@alerque
Copy link
Collaborator

alerque commented Sep 15, 2021

We already have a PR mentioning the parent container method, see #11. Note this does have a downside of not being able to run other Action tooling via uses: as easily because many of them depend on the tooling in the Ubuntu base images.

That aside, the container trick in itself doesn't answer your original question because it doesn't have the other tooling you need in the Pandoc image. Making your own image with your own tools is certainly viable (and what I recommended above) but I'm not sure how best to document that as there are so many possible variants of that with different distros, places to keep sources or images, etc. It can be done via external images as you've done or even in the same project (you can use a Dockerfile from the current repo to run containers in CI).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants