About: Researcher and educator in A.I., algorithms, evolutionary computation, machine learning, and swarm intelligence
Location:
NJ
Joined:
Sep 14, 2020
pyaction: Python and the GitHub CLI in a Docker Container
Publish Date: Aug 14
6 2
TL;DR
The pyaction container is a Python slim Docker container with the addition of the GitHub CLI, git, curl, and gpg. Its original motivation was to support developing GitHub Actions with Python, but pyaction can also be used for other purposes (e.g., as an alternate way of using the GitHub CLI). Due to several requests from pyaction users, who wanted to use it with earlier Python versions, we recently changed the tagging convention. The Docker tags for pulling pyaction now include tags specifying the version of Python, and optionally the version of the GitHub CLI that are included in the image. The pyaction container is published to both Docker Hub and the GitHub Container Registry.
The maintainers of pyaction are not affiliated with GitHub; and pyaction is an unofficial installation of the GitHub CLI.
The original motivation for pyaction was to support implementing GitHub Actions in Python as a container actions. Container actions enable implementing a GitHub Action in any language, one only needs a Docker container that includes the relevant language tools (e.g., interpreter, etc) and any other tools needed. To implement a GitHub Action in Python, this would require, at a minimum, Python. Thus, a Python slim image is used as the base of pyaction. A "slim" image is specifically used to keep the container small for faster loading from workflows. The GitHub CLI is then added to the container to enable interfacing with all things GitHub. The GitHub Actions framework itself has the GitHub CLI installed, however, container actions are limited to running only what is installed within the container itself. The pyaction container also has curl installed. Although GitHub Actions is the motivating usecase, pyaction is not limited to this case.
Previously, we were using Semantic Versioning for the Docker tags, with each version having a specific combination of Python version and GitHub CLI version. We started getting requests from users of pyaction images with current GitHub CLI and earlier versions of Python. For example, perhaps their application wasn't ready for the next version of Python.
So, to meet these requests, we changed the tagging convention, such that tags include the Python version and optionally the GitHub CLI version. And we started publishing images for older Python versions whenever GitHub releases a new version of the GitHub CLI. At the present time, pyaction supports Python 3.8, 3.9, 3.10, 3.11, 3.12, and 3.13. Images are tagged as follows:
For the current version of Python (e.g., 3.13.6) and current version of GitHub CLI (e.g., 2.76.2), all of the following tags are available and equivalent: latest, 3.13.6, 3.13, 3.13.6-gh-2.76.2, 3.13.6-gh-2.76, 3.13.6-gh-2, 3.13-gh-2.76.2, 3.13-gh-2.76, 3.13-gh-2.
For prior versions of Python (3.8, 3.9, 3.10, 3.11, 3.12) and current version of GitHub CLI (2.76.2), all of the following tags are available and equivalent: 3.12, 3.12-gh-2.76.2, 3.12-gh-2.76, 3.12-gh-2.
This tag scheme began with version 2.75.0 of the GitHub CLI. We don't support pyaction images with earlier versions of the GitHub CLI (other than via older images published with the prior tagging scheme).
This tag scheme began with Python 3.13.5. Python patch level tags are not available for pyaction prior to Python 3.13.5.
Installing
The pre-built image is hosted on both Docker Hub and the GitHub Container Registry. You can use it in the following ways.
Docker Pull Command
Pull the latest image from Docker Hub with the following (or replace the latest tag with the desired version):
docker pull cicirello/pyaction:latest
Pull from the Github Container Registry with:
docker pull ghcr.io/cicirello/pyaction:latest
Use as a base image in a Dockerfile
Use as a base image in a Dockerfile (or replace the latest tag with the desired version):
FROM cicirello/pyaction:latest# The rest of your Dockerfile would go here.
Or you can use as a base image (via the Github Container Registry) with:
FROM ghcr.io/cicirello/pyaction:latest# The rest of your Dockerfile would go here.
More Information
For more information about pyaction, see earlier posts here on DEV in this series, as well as an information page about pyaction on the web.
The pyaction Docker container is designed to support implementing Github Actions with Python. It starts with the official python slim docker image as the base, using slim to keep the image size down for faster loading of Github Actions that use pyaction. The pyaction container also includes curl, gpg, git, and the GitHub CLI.
actions.cicirello.org
Please consider starring pyaction's GitHub repository, and even better using it to develop GitHub Actions, or just to use the GitHub CLI:
This Docker image is designed to support implementing Github Actions
with Python. It starts with the official python docker image
as the base, which is a Debian OS. It specifically uses python:3-slim to keep the image size
down for faster loading of Github Actions that use pyaction. On top of the
base, we've installed curlgpg, git, and the
GitHub CLI. We added curl and gpg because they
are needed to install the GitHub CLI, and they may come in handy anyway
(especially curl) when implementing a GitHub Action.
That’s a really helpful explanation about using Python with GitHub CLI inside Docker. For anyone who also enjoys combining automation with astrology-based tools, you might find this Professional Transit Calculator useful for mapping planetary movements in a structured way. It gives clear insights that can be integrated into personal projects or research. Thanks for sharing this post—it definitely adds value to workflow discussions!
Interesting information, thank you!