Skip to content

Commit 4f67e53

Browse files
authored
Gracefully fall back to local configs when GitHub is unreachable (#3010)
* Gracefully handle config repo update failures When the config repo is already cloned, fall back to existing local configs instead of crashing if GitHub is unreachable. Fixes #2980 * Adjust after PR comments
1 parent 0135b87 commit 4f67e53

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

openvpn/fetch-external-configs.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,17 @@ elif [[ "${VPN_CONFIG_SOURCE_TYPE}" == "github_clone" ]]; then
6060
GITHUB_CONFIG_SOURCE_LOCAL=$(git -C "${config_repo}" remote -v | head -1 | awk '{print $2}' | sed -e 's/https:\/\/github.com\///' -e 's/.git//')
6161
if [ "$GITHUB_CONFIG_SOURCE_LOCAL" == "$GITHUB_CONFIG_SOURCE_REPO" ]; then
6262
echo "Repository is already cloned, updating"
63-
git -C "${config_repo}" fetch origin
64-
git -C "${config_repo}" reset --hard origin/${GITHUB_CONFIG_SOURCE_REVISION}
65-
git -C "${config_repo}" clean -fd
63+
if git -C "${config_repo}" fetch origin; then
64+
if git -C "${config_repo}" reset --hard "origin/${GITHUB_CONFIG_SOURCE_REVISION}" && \
65+
git -C "${config_repo}" clean -fd; then
66+
echo "Repository updated successfully"
67+
else
68+
echo "ERROR: Fetched from origin but failed to reset to ${GITHUB_CONFIG_SOURCE_REVISION} or clean ${config_repo}"
69+
exit 1
70+
fi
71+
else
72+
echo "WARNING: Could not fetch from ${GITHUB_CONFIG_REPO_URL} (network or GitHub unavailable); continuing with existing local configs"
73+
fi
6674
else
6775
echo "Cloning ${GITHUB_CONFIG_REPO_URL} into ${config_repo}"
6876
config_repo_old="${config_repo}_old"

0 commit comments

Comments
 (0)