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 12
12
"mounts" : [
13
13
" source=/usr/local/gitpod/config/,target=/usr/local/gitpod/config/,type=bind"
14
14
],
15
+ "onCreateCommand" : " bash /workspace/gitpod/dev/setup-github-auth.sh" ,
15
16
"remoteEnv" : {
16
17
"GIT_EDITOR" : " code --wait" ,
17
18
"KUBE_EDITOR" : " code --wait"
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ tasks:
47
47
leeway run components/local-app:install-cli
48
48
leeway run components/local-app:cli-completion
49
49
exit 0
50
+ - name : Setup GitHub CLI Auth
51
+ init : |
52
+ bash /workspace/gitpod/dev/setup-github-auth.sh
53
+ exit 0
50
54
# This task takes care of configuring your workspace so it can manage and interact
51
55
# with preview environments.
52
56
- 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