Skip to content

Commit dd3e2ab

Browse files
committed
use gh cli to force codespace full rebuild
1 parent c5f8eeb commit dd3e2ab

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ RUN apt update && \
139139
xvfb && \
140140
apt clean
141141

142+
142143
# Install GitHub CLI
143144
RUN (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
144145
&& sudo mkdir -p -m 755 /etc/apt/keyrings \

update50.sh

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#!/bin/bash
22

3+
# Check for gh and install it if not available (temporary)
4+
if ! command -v gh &> /dev/null; then
5+
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
6+
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
7+
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
8+
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
9+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
10+
&& sudo apt update \
11+
&& sudo apt install gh -y
12+
fi
13+
314
# Check for -t flag for develop mode
415
if [ "$1" == "-t" ]; then
516
# Use the specified tag to build the URL
@@ -12,7 +23,19 @@ if [ "$1" == "-t" ]; then
1223
echo "Could not update codespace with tag $tag. Try again later."
1324
exit 1
1425
fi
15-
command50 github.codespaces.rebuildEnvironment
26+
27+
# Trigger rebuild
28+
if command -v gh &> /dev/null; then
29+
30+
# Use gh cli to rebuild if available
31+
gh cs rebuild --repo $GITHUB_REPOSITORY --full
32+
echo "Your codespace is now being rebuilt, please keep the browser window open and wait for it to reload.\nDo not perform any actions until the rebuild is complete."
33+
else
34+
35+
# Fall back to command50
36+
command50 github.codespaces.rebuildEnvironment
37+
fi
38+
1639
exit 0
1740
fi
1841

@@ -46,7 +69,16 @@ if [ "$remote" != "$local" ] || [ "$tag" != "$issue" ] || [ "$1" == "-f" ] || [
4669
echo "$remote" > "/workspaces/$RepositoryName/.devcontainer.json"
4770

4871
# Trigger rebuild
49-
command50 github.codespaces.rebuildEnvironment
72+
if command -v gh &> /dev/null; then
73+
74+
# Use gh cli to rebuild if available
75+
gh cs rebuild --repo $GITHUB_REPOSITORY --full
76+
echo "Your codespace is now being rebuilt, please keep the browser window open and wait for it to reload.\nDo not perform any actions until the rebuild is complete."
77+
else
78+
79+
# Fall back to command50
80+
command50 github.codespaces.rebuildEnvironment
81+
fi
5082

5183
else
5284
echo "Your codespace is already up-to-date!"

0 commit comments

Comments
 (0)