This repository maintains a Docker image for the GitHub CLI gh, enabling users to interact with GitHub from within a Docker container. This Docker image facilitates seamless integration of GitHub workflows into Dockerized environments, making it easier for developers, DevOps teams, and automation workflows to leverage GitHub functionalities without needing to install the CLI on their systems directly.
To pull the Docker image and start using the GitHub CLI, run:
docker pull v17v3/gh:latest
docker run -it v17v3/gh:latest
You can use the GitHub CLI in a Docker container by running:
docker run -it v17v3/gh:latest <command>
For example, to list your repos:
docker run -it v17v3/gh:latest repo list
It can be useful to have a bash function to avoid typing the whole docker command:
gh() {
docker run --rm -i -v "${PWD}":/workdir v17v3/gh:latest "$@"
}
To authenticate with GitHub using your Dockerized gh
CLI:
- Generate a personal access token (PAT) from GitHub with the appropriate scopes.
- Run the container and pass your PAT:
docker run -it -e GH_TOKEN="<your-personal-access-token>" v17v3/gh:latest
To build this Docker image from source:
- Clone this repository:
git clone https://github.com/vv173/gh.git
cd gh/
- Build the image with:
docker buildx build --build-arg GH_CLI_VERSION=2.49.1 --push -t gh:latest .
To ensure the integrity and authenticity of the Docker image, you can verify its signature using cosign. Here's how to do it:
cosign verify --key cosign.pub v17v3/gh:latest
Contributions to improve the Docker image or fix issues are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch for your feature or fix.
- Commit your changes with clear, descriptive messages.
- Push your branch and submit a pull request against the main branch.
This Docker image and its contents are released under the MIT License. See LICENSE for more details.