Skip to content

Commit 7a603bf

Browse files
committed
Add gh cli
1 parent 174ceda commit 7a603bf

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

.devcontainer/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,10 @@ RUN \
6363

6464
# Switch back to dialog for any ad-hoc use of apt-get
6565
ENV DEBIAN_FRONTEND=dialog
66+
67+
# gh
68+
COPY scripts/gh.sh /tmp/
69+
RUN /tmp/gh.sh
70+
71+
# symlink gh config folder
72+
RUN echo 'if [[ ! -d /home/vscode/.config/gh ]]; then mkdir -p /home/vscode/.config; ln -s /config/gh /home/vscode/.config/gh; fi ' >> ~/.bashrc

.devcontainer/devcontainer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,11 @@
6161
"postCreateCommand": "make post-create",
6262

6363
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
64-
"remoteUser": "vscode"
64+
"remoteUser": "vscode",
65+
"mounts": [
66+
// Mounts the .config/gh host folder into the dev container to pick up host gh CLI login details
67+
// NOTE that mounting directly to ~/.config/gh makes ~/.config only root-writable
68+
// Instead monut to another location and symlink in Dockerfile
69+
"type=bind,source=${env:HOME}${env:USERPROFILE}/.config/gh,target=/config/gh",
70+
],
6571
}

.devcontainer/scripts/gh.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -e
3+
4+
get_latest_release() {
5+
curl --silent "https://api.github.com/repos/$1/releases/latest" |
6+
grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/'
7+
}
8+
9+
VERSION=${1:-"$(get_latest_release cli/cli)"}
10+
INSTALL_DIR=${2:-"$HOME/.local/bin"}
11+
CMD=gh
12+
NAME="GitHub CLI"
13+
14+
echo -e "\e[34m»»» 📦 \e[32mInstalling \e[33m$NAME \e[35mv$VERSION\e[0m ..."
15+
16+
mkdir -p $INSTALL_DIR
17+
curl -sSL https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_amd64.tar.gz -o /tmp/gh.tar.gz
18+
tar -zxvf /tmp/gh.tar.gz --strip-components 2 -C $INSTALL_DIR gh_${VERSION}_linux_amd64/bin/gh > /dev/null
19+
chmod +x $INSTALL_DIR/gh
20+
rm -rf /tmp/gh.tar.gz
21+
22+
echo -e "\n\e[34m»»» 💾 \e[32mInstalled to: \e[33m$(which $CMD)"
23+
echo -e "\e[34m»»» 💡 \e[32mVersion details: \e[39m$($CMD --version)"

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ require (
77
github.com/bradford-hamilton/dora v0.1.1
88
github.com/kyoh86/richgo v0.3.6 // indirect
99
github.com/kyoh86/xdg v1.2.0 // indirect
10-
github.com/mattn/go-isatty v0.0.12 // indirect
10+
github.com/mattn/go-isatty v0.0.13 // indirect
1111
github.com/morikuni/aec v1.0.0 // indirect
1212
github.com/nats-io/nats.go v1.8.1
1313
github.com/rhysd/go-github-selfupdate v1.2.2
1414
github.com/spf13/cobra v1.0.0
1515
github.com/spf13/viper v1.4.0
1616
github.com/stretchr/testify v1.7.0
1717
github.com/wacul/ptr v1.0.0 // indirect
18-
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
18+
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b // indirect
1919
gopkg.in/yaml.v2 v2.4.0 // indirect
2020
)
2121

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ github.com/mattn/go-isatty v0.0.0-20170925054904-a5cdd64afdee h1:tUyoJR5V1TdXnTh
8181
github.com/mattn/go-isatty v0.0.0-20170925054904-a5cdd64afdee/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
8282
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
8383
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
84+
github.com/mattn/go-isatty v0.0.13 h1:qdl+GuBjcsKKDco5BsxPJlId98mSWNKqYA+Co0SC1yA=
85+
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
8486
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
8587
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
8688
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
@@ -190,6 +192,8 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
190192
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
191193
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
192194
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
195+
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b h1:qh4f65QIVFjq9eBURLEYWqaEXmOyqdUyiBSgaXWccWk=
196+
golang.org/x/sys v0.0.0-20210601080250-7ecdf8ef093b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
193197
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
194198
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
195199
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

0 commit comments

Comments
 (0)