diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ad3b09e..9e80168 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,6 +27,7 @@ jobs: - dozzle.dev - devenv.sh - feature-installer + - github.com-cli - helix-editor.com - jj-vcs.dev - mosh.org @@ -79,6 +80,7 @@ jobs: - dozzle.dev - devenv.sh - feature-installer + - github.com-cli - helix-editor.com - jj-vcs.dev - mosh.org diff --git a/src/github.com-cli/README.md b/src/github.com-cli/README.md new file mode 100644 index 0000000..efcf906 --- /dev/null +++ b/src/github.com-cli/README.md @@ -0,0 +1,24 @@ + +# github.com-cli (github.com-cli) + +Install "gh" (GitHub CLI) binary + +## Example Usage + +```json +"features": { + "ghcr.io/devcontainer-community/devcontainer-features/github.com-cli:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | Currently unused. gh is installed via the official GitHub CLI apt repository. | string | latest | + + + +--- + +_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/devcontainer-community/devcontainer-features/blob/main/src/github.com-cli/devcontainer-feature.json). Add additional notes to a `NOTES.md`._ diff --git a/src/github.com-cli/devcontainer-feature.json b/src/github.com-cli/devcontainer-feature.json new file mode 100644 index 0000000..3070148 --- /dev/null +++ b/src/github.com-cli/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "name": "github.com-cli", + "id": "github.com-cli", + "version": "1.0.0", + "description": "Install \"gh\" (GitHub CLI) binary", + "documentationURL": "https://github.com/devcontainer-community/devcontainer-features/tree/main/src/github.com-cli", + "options": { + "version": { + "type": "string", + "default": "latest", + "proposals": [ + "latest" + ], + "description": "Currently unused. gh is installed via the official GitHub CLI apt repository." + } + } +} diff --git a/src/github.com-cli/install.sh b/src/github.com-cli/install.sh new file mode 100755 index 0000000..7d47b34 --- /dev/null +++ b/src/github.com-cli/install.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -o errexit +set -o pipefail +set -o noclobber +set -o nounset +set -o allexport +readonly name="gh" +apt_get_update() { + if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then + echo "Running apt-get update..." + apt-get update -y + fi +} +apt_get_checkinstall() { + if ! dpkg -s "$@" >/dev/null 2>&1; then + apt_get_update + DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends --no-install-suggests --option 'Debug::pkgProblemResolver=true' --option 'Debug::pkgAcquire::Worker=1' "$@" + fi +} +apt_get_cleanup() { + apt-get clean + rm -rf /var/lib/apt/lists/* +} +echo_banner() { + local text="$1" + echo -e "\e[1m\e[97m\e[41m$text\e[0m" +} +install() { + apt_get_checkinstall curl ca-certificates + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg \ + | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg + chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" \ + | tee /etc/apt/sources.list.d/github-cli.list > /dev/null + apt-get update -y + apt_get_checkinstall gh + apt_get_cleanup +} +echo_banner "devcontainer.community" +echo "Installing $name..." +install "$@" +echo "(*) Done!" diff --git a/test/github.com-cli/test.sh b/test/github.com-cli/test.sh new file mode 100755 index 0000000..df5b2c2 --- /dev/null +++ b/test/github.com-cli/test.sh @@ -0,0 +1,18 @@ +#!/bin/bash + + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +# See https://github.com/devcontainers/cli/blob/HEAD/docs/features/test.md#dev-container-features-test-lib +# Provides the 'check' and 'reportResults' commands. +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. Syntax is... +# check