Skip to content

Commit

Permalink
use gh cli to force codespace full rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
rongxin-liu committed Nov 6, 2024
1 parent c5f8eeb commit dd3e2ab
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ RUN apt update && \
xvfb && \
apt clean


# Install GitHub CLI
RUN (type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
Expand Down
36 changes: 34 additions & 2 deletions update50.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#!/bin/bash

# Check for gh and install it if not available (temporary)
if ! command -v gh &> /dev/null; then
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& 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 \
&& sudo apt update \
&& sudo apt install gh -y
fi

# Check for -t flag for develop mode
if [ "$1" == "-t" ]; then
# Use the specified tag to build the URL
Expand All @@ -12,7 +23,19 @@ if [ "$1" == "-t" ]; then
echo "Could not update codespace with tag $tag. Try again later."
exit 1
fi
command50 github.codespaces.rebuildEnvironment

# Trigger rebuild
if command -v gh &> /dev/null; then

# Use gh cli to rebuild if available
gh cs rebuild --repo $GITHUB_REPOSITORY --full
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."
else

# Fall back to command50
command50 github.codespaces.rebuildEnvironment
fi

exit 0
fi

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

# Trigger rebuild
command50 github.codespaces.rebuildEnvironment
if command -v gh &> /dev/null; then

# Use gh cli to rebuild if available
gh cs rebuild --repo $GITHUB_REPOSITORY --full
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."
else

# Fall back to command50
command50 github.codespaces.rebuildEnvironment
fi

else
echo "Your codespace is already up-to-date!"
Expand Down

0 comments on commit dd3e2ab

Please sign in to comment.