File tree Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Expand file tree Collapse file tree 4 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1212 "mounts" : [
1313 " source=/usr/local/gitpod/config/,target=/usr/local/gitpod/config/,type=bind"
1414 ],
15+ "onCreateCommand" : " bash /workspace/gitpod/dev/setup-github-auth.sh" ,
1516 "remoteEnv" : {
1617 "GIT_EDITOR" : " code --wait" ,
1718 "KUBE_EDITOR" : " code --wait"
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ tasks:
4747 leeway run components/local-app:install-cli
4848 leeway run components/local-app:cli-completion
4949 exit 0
50+ - name : Setup GitHub CLI Auth
51+ init : |
52+ bash /workspace/gitpod/dev/setup-github-auth.sh
53+ exit 0
5054 # This task takes care of configuring your workspace so it can manage and interact
5155 # with preview environments.
5256 - name : Preview environment configuration
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # GitHub Token Helper
4+ # Dynamically retrieves GitHub token from git credentials
5+ # Safe to source - will not error if git credentials are unavailable
6+
7+ # Only set GH_TOKEN if not already set and git credential is available
8+ if [ -z " $GH_TOKEN " ] && command -v git > /dev/null 2>&1 ; then
9+ # Attempt to get token from git credentials, suppress errors
10+ TOKEN=$( printf ' protocol=https\nhost=github.com\n' | git credential fill 2> /dev/null | awk -F= ' /password/ {print $2}' 2> /dev/null)
11+
12+ # Only export if we got a non-empty token
13+ if [ -n " $TOKEN " ]; then
14+ export GH_TOKEN=" $TOKEN "
15+ fi
16+
17+ unset TOKEN
18+ fi
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # GitHub CLI Authentication Setup
4+ # Adds sourcing of GitHub token helper to shell profiles
5+
6+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
7+ GITHUB_TOKEN_HELPER=" $SCRIPT_DIR /github-token.sh"
8+
9+ {
10+ echo " "
11+ echo " # GitHub token helper"
12+ echo " source \" $GITHUB_TOKEN_HELPER \" "
13+ } >> ~ /.bashrc
14+
15+ {
16+ echo " "
17+ echo " # GitHub token helper"
18+ echo " source \" $GITHUB_TOKEN_HELPER \" "
19+ } >> ~ /.zshrc
20+
21+ source " $GITHUB_TOKEN_HELPER "
22+
23+ echo " ✅ GitHub CLI configured"
You can’t perform that action at this time.
0 commit comments