Skip to content

Commit

Permalink
Update ghcli with multi env support
Browse files Browse the repository at this point in the history
  • Loading branch information
snigdhasjg committed Oct 22, 2024
1 parent 94254e2 commit fd8ae63
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
no-cache: true
push: true
tags: ${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.directories }}:latest,${{ vars.DOCKERHUB_USERNAME }}/${{ matrix.directories }}:${{ steps.metadata.outputs.git_tag }}
platforms: linux/amd64 # ,linux/arm64/v8
platforms: linux/amd64,linux/arm64/v8
labels: |
org.opencontainers.image.title=${{ matrix.directories }}
org.opencontainers.image.url=${{ github.repositoryUrl }}
Expand Down
30 changes: 10 additions & 20 deletions ghcli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
FROM debian:bookworm-slim

RUN set -ex; \
apt-get update ; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
jq; \
FROM debian:trixie-slim

RUN apt update && \
apt-get install ca-certificates wget curl git jq -y --no-install-recommends && \
mkdir -p -m 755 /etc/apt/keyrings && \
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null && \
chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg && \
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null && \
apt update && \
apt install gh -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*

ENV GITHUB_CLI_VERSION 2.48.0

RUN set -ex; \
curl -L "https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_checksums.txt" -o checksums.txt; \
curl -OL "https://github.com/cli/cli/releases/download/v${GITHUB_CLI_VERSION}/gh_${GITHUB_CLI_VERSION}_linux_amd64.deb"; \
shasum --ignore-missing -a 512 -c checksums.txt; \
dpkg -i "gh_${GITHUB_CLI_VERSION}_linux_amd64.deb"; \
rm -rf "gh_${GITHUB_CLI_VERSION}_linux_amd64.deb"; \
# verify gh binary works
gh --version;

ENTRYPOINT [ "gh" ]
65 changes: 64 additions & 1 deletion ghcli/docs/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
Welcome to GitHub Cli
Welcome to GitHub CLI

This Docker image provides a lightweight environment to run the GitHub CLI (`gh`) on a Debian-based system. It’s perfect for integrating GitHub commands into your CI/CD pipelines or any automated workflows.

## Features

- **Base Image**: Built on `debian:trixie-slim` for a minimal footprint.
- **Installed Tools**:
- `curl`
- `git`
- `jq`
- `ca-certificates`
- **GitHub CLI**: The latest version of GitHub CLI installed.

## Getting Started

### Prerequisites

Make sure you have Docker installed on your machine. You can download it from [Docker's official website](https://www.docker.com/get-started).

### Build the Image

To build the Docker image, navigate to the directory containing the `Dockerfile` and run:

```bash
docker build -t github-cli .
```

### Run the Container

To run the GitHub CLI in a new container, use:

```bash
docker run --rm -it github-cli
```

You can pass any `gh` command as an argument. For example:

```bash
docker run --rm -it github-cli auth login
```

## Usage

Once inside the container, you can use the `gh` commands just like you would on your local machine. For example:

```bash
gh repo list
```

## Contributing

If you want to contribute to this project, feel free to fork the repository and submit a pull request.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Thanks to the [GitHub CLI team](https://github.com/cli/cli) for their excellent work on the tool.
- Inspired by the Debian community for providing a robust base image.

Enjoy using the GitHub CLI in your Dockerized environments!

0 comments on commit fd8ae63

Please sign in to comment.