Skip to content

Instantly share code, notes, and snippets.

@aslafy-z
Created August 2, 2024 07:24
Show Gist options
  • Save aslafy-z/22ceaa1a47d433a074dc9bc0e2e3e4cd to your computer and use it in GitHub Desktop.
Save aslafy-z/22ceaa1a47d433a074dc9bc0e2e3e4cd to your computer and use it in GitHub Desktop.
#!/bin/sh
git_endpoint=https://
git_branch=main
git_username=foo
git_password=bar
if [ -n "$git_username" ] && [ -n "$git_password" ] && echo "$git_endpoint" | grep -qE '^https?://'; then
encoded_git_username=$(echo "$git_username" | yq @uri)
encoded_git_password=$(echo "$git_password" | yq @uri)
git_endpoint=$(echo "$git_endpoint" | sed "s|//|//${encoded_git_username}:${encoded_git_password}@|")
fi
while true; do
rm -rf .git
git init --initial-branch "$git_branch"
git config user.name "$git_username"
git config user.email "$git_username@k8saas.io"
git remote add origin "$git_endpoint"
git fetch || continue
git checkout "$git_branch" || git checkout -b $git_branch
git rm -rf --ignore-unmatch .
git clean -fxd
cp -r ../source/. .
git add .
git commit -m "Updated ⭐"
git push origin "$git_branch" || continue
break
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment