Last active
September 2, 2023 19:34
-
-
Save giolvani/2901f9b053fb054f0d1c4af3935f6841 to your computer and use it in GitHub Desktop.
Manual update from github (a dummy alternative to the github actions)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APPLICATION_URL=http://localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
GIT_USER=git_user | |
GIT_API_TOKEN=git_token | |
GIT_REPO=git_repo | |
DEST_DIR=release_dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CF=~/.git-env.sh | |
TIMESTAMP=$(date +%Y-%m-%d_%H:%M:%S.%6N) | |
function info { | |
cat <<- INFO | |
-- Script for downloading PRIVATE(!) git-repos as tar-archive on old systems (like Debian Etch) | |
-- That only have old git - binaries | |
-- | |
-- You need a to create a token, to let it work on, see also: | |
-- https://help.github.com/articles/creating-an-access-token-for-command-line-use/ | |
INFO | |
} | |
function setVariablesAndWrite { | |
echo "GIT-User ?" | |
read GIT_USER | |
echo "GIT-Api-Token ? " | |
read GIT_API_TOKEN | |
echo "GIT-Repo" | |
read GIT_REPO | |
echo "DEST-Dir ? (Where to copy the repo (full-path) -> This also replaces the repo-name)" | |
read DEST_DIR | |
touch $CF | |
echo "#!/bin/bash" > $CF | |
echo "GIT_USER=${GIT_USER}" >> $CF | |
echo "GIT_API_TOKEN=${GIT_API_TOKEN}" >> $CF | |
echo "GIT_REPO=${GIT_REPO}" >> $CF | |
echo "DEST_DIR=${DEST_DIR}" >> $CF | |
# securing it against all odds | |
chown root:root $CF | |
chmod 400 $CF | |
} | |
function backupCurrentRelease { | |
if [ -d $DEST_DIR ] | |
then | |
mv $DEST_DIR $DEST_DIR"."$TIMESTAMP | |
fi | |
} | |
function rewriteAndMoveSource { | |
LOCAL_REPO_DIR=$(ls | head -n1) | |
mv $LOCAL_REPO_DIR $DEST_DIR | |
} | |
function setupEnvFile { | |
cp ~/.env.sample $DEST_DIR"/.env" | |
} | |
info | |
if [ -f $CF ] | |
then | |
# Security option | |
chmod 400 $CF | |
. $CF | |
else | |
setVariablesAndWrite | |
fi | |
echo "===> Creating temporary directory" | |
TMP_DEST_DIR=$(mktemp -t -p $PWD -d) | |
echo "===> Entering $TMP_DEST_DIR directory"; | |
cd $TMP_DEST_DIR | |
echo "===> Downloading source" | |
curl -L -k -u token:${GIT_API_TOKEN} https://github.com/${GIT_USER}/${GIT_REPO}/tarball/main | tar -xz | |
echo "===> Backup current release directory" | |
backupCurrentRelease | |
echo "===> Moving new source code to release directory" | |
rewriteAndMoveSource | |
echo "===> Setting up .env file" | |
setupEnvFile | |
echo "===> Deleting temporary directory" | |
rm -rf $TMP_DEST_DIR | |
echo "===> New Version is now available under: $DEST_DIR <===" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment