forked from driesvints/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbootstrap-codespaces
More file actions
executable file
·70 lines (61 loc) · 2.82 KB
/
bootstrap-codespaces
File metadata and controls
executable file
·70 lines (61 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
cd "$(dirname "$0")"
source ./helpers/runtime.sh
source ../bin/helpers/trap_and_trace.sh
# You can add a script file to your dotfiles repo that will be executed when the
# dotfiles are loaded into your Codespaces. You do have to give it the proper
# name, but GitHub gives you several to choose from. When Codespaces detects a
# script file in your dotfiles repo, it clones the dotfiles repo to
# "/workspaces/.codespaces/.persistedshare/dotfiles" and then executes your
# script file if it exists. If it does not find an applicable script file then
# it will copy and files starting with "." from the dotfiles directory to the
# $HOME folder in the codespace. If it does find a script, then it expects the
# script to copy over the dotfiles to the correct place.
#
# https://docs.github.com/en/codespaces/setting-your-user-preferences/personalizing-github-codespaces-for-your-account#dotfiles
log_info "Bootstrapping codespaces"
if [[ "$(is_codespace)" != "true" ]]; then
log_attention "Not a codespace; skipping $0"
exit 0
fi
# Run setup steps that apply both locally and in devcontainers
./bootstrap-common
# ENV variables we could evaluate in a Codespace:
# CLOUDENV_ENVIRONMENT_ID=very-long-guid-hash
# CODESPACES=true # Always true if set
# CODESPACES_RECOVERY_CONTAINER=true|false
# CODESPACE_NAME=name-plus-guid
# CODESPACE_VSCODE_FOLDER=/workspaces/mycoolapp
# CONTAINER_BUILDER_TOKEN=github-token
# GITHUB_API_URL=https://api.github.com
# GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN=app.github.dev
# GITHUB_CODESPACE_TOKEN=LONG_TOKEN
# GIT_COMMITTER_EMAIL=noreply@github.com
# GITHUB_GRAPHQL_URL=https://api.github.com/graphql
# GITHUB_REPOSITORY=me/mycoolapp
# GITHUB_SERVER_URL=https://github.com
# GITHUB_TOKEN=another-github-token
# GITHUB_USER=me
# HOST=codespaces-${short-token}
# HOSTNAME=codespaces-${short-token}
# RepositoryName=mycoolapp
# TERM_PROGRAM=vscode # Could also be "codespaces"
if [[ -n "$(git config get --global url."git@github.com:".insteadOf)" ]]; then
log_info "Configuring git for codespaces"
# This insteadOf line doesn't work on Codespaces, so we need to unset it
git config unset --global url."git@github.com:".insteadOf
else
log_verbose "No git insteadOf config found; skipping"
fi
if [[ -n $(command -v gh 2>/dev/null) ]]; then
log_attention "Installing credentials helper via gh CLI. Watch for prompts."
gh auth setup-git
else
log_attention "gh CLI not found; skipping credentials helper installation"
fi
SOURCE_HOMEBREW_SILENT=true source ./helpers/source_homebrew.sh
if [[ -n $(command -v brew 2>/dev/null) ]]; then
log_info "Adding Homebrew evals to shell profiles"
add_eval_to_dotfile "[[ -f \"${HOMEBREW_PREFIX}/bin/brew\" ]]" "\"${HOMEBREW_PREFIX}/bin/brew\" shellenv" "${HOME}/.bash_profile" "${HOME}/.zprofile"
fi
log_success "Done codespace specific bootstrapping!"