Skip to content

Instantly share code, notes, and snippets.

@twfahey1
Created May 23, 2022 19:19
Show Gist options
  • Save twfahey1/465d5ab744b91e26c290b4deb69defaf to your computer and use it in GitHub Desktop.
Save twfahey1/465d5ab744b91e26c290b4deb69defaf to your computer and use it in GitHub Desktop.
Github Actions - Use a Dockerfile to do some work in a step

The idea is that any Docker image can be used inside the Github Action to perform a unit of work. In this example, we use an Docker image that is intended to compile our Sphinx build files. It mounts the work directory, in this case we want it on the image docs folder, launches the container and runs the make html command inside the container, which compiles the code into HTML, and places it into a folder output. The work directory is mounted to the docker container, so even ater it shuts down, we are left with the resulting files. Subsequent steps can access this directory as expected, and do whatever with it, e.g. deploy it to our server.

jobs:
do-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build via Docker
uses: addnab/docker-run-action@v3
with:
image: utmoodycollege/utdk_docs_builder:1.0-amd64
options: -v ${{ github.workspace }}:/docs
run: |
make html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment