File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -134,20 +134,22 @@ requiredenvs() {
134
134
}
135
135
136
136
gh_auth () {
137
- local fail=0
138
- if [[ " ${CODER:- } " == " true" ]]; then
139
- if ! output=$( coder external-auth access-token github 2>&1 ) ; then
140
- log " ERROR: Could not authenticate with GitHub."
141
- log " $output "
142
- fail=1
137
+ if [[ -z ${GITHUB_TOKEN:- } ]]; then
138
+ if [[ -n ${GH_TOKEN:- } ]]; then
139
+ export GITHUB_TOKEN=${GH_TOKEN}
140
+ elif [[ ${CODER:- } == true ]]; then
141
+ if ! output=$( coder external-auth access-token github 2>&1 ) ; then
142
+ # TODO(maf): We could allow checking `gh auth token` here.
143
+ log " ${output} "
144
+ error " Could not authenticate with GitHub using Coder external auth."
145
+ else
146
+ export GITHUB_TOKEN=${output}
147
+ fi
148
+ elif token=" $( gh auth token --hostname github.com 2> /dev/null) " ; then
149
+ export GITHUB_TOKEN=${token}
143
150
else
144
- GITHUB_TOKEN=$( coder external-auth access-token github)
145
- export GITHUB_TOKEN
151
+ error " GitHub authentication is required to run this command, please set GITHUB_TOKEN or authenticate run 'gh auth login'."
146
152
fi
147
- elif token=" $( gh auth token --hostname github.com 2> /dev/null) " ; then
148
- export GITHUB_TOKEN=$token
149
- else
150
- log " Please authenticate gh CLI by running 'gh auth login'"
151
153
fi
152
154
}
153
155
You can’t perform that action at this time.
0 commit comments