Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Arjan Dikhoff committed Oct 25, 2024
1 parent f0b9ffa commit b40f2df
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

# Init env vars

DATE=`date`
WORK_DIR=`pwd`
REPORT_DIR="$WORK_DIR/build-report"
REPORT_FILE="$REPORT_DIR/index.html"
date=`date`
workDir=`pwd`
reportDir="$workDir/build-report"
reportFile="$reportDir/index.html"

GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
gitBranch=`git rev-parse --abbrev-ref HEAD`
if [ -n "$CF_PAGES" ]
then
echo "We are on Cloudflare Pages. Retrieve branch from env."
GIT_BRANCH=$CF_PAGES_BRANCH
gitBranch=$CF_PAGES_BRANCH
fi
GIT_COMMIT_MESSAGE="branch $GIT_BRANCH on $DATE"
GIT_LIVE_BRANCH=${2:-develop}
gitCommitMessage="branch $gitBranch on $date"
redotDocsLiveBranch=${2:-develop}

INPUT_DIR="."
MIGRATE_DIR="_migrated"
Expand All @@ -23,17 +23,17 @@ REPO_DIR="_repo"

LIVE_ROOT="redot-docs-live"
LIVE_REPO="[email protected]:Redot-Engine/$LIVE_ROOT.git"
BUILD_DIR="html/en/$GIT_BRANCH"
BUILD_DIR="html/en/$gitBranch"

# Report vars and intention

mkdir -p $REPORT_DIR
rm $REPORT_FILE
echo "reporting to $REPORT_FILE"
echo "Building $GIT_COMMIT_MESSAGE"
echo "Live branch: $GIT_LIVE_BRANCH"
mkdir -p $reportDir
rm $reportFile
echo "reporting to $reportFile"
echo "Building $gitCommitMessage"
echo "Live branch: $redotDocsLiveBranch"
echo "Temp dirs: $MIGRATE_DIR, $SPHINX_DIR, $REPO_DIR"
echo "Live root: $LIVE_ROOT, live repo: $LIVE_REPO, build dir: $BUILD_DIR, report dir: $REPORT_DIR"
echo "Live root: $LIVE_ROOT, live repo: $LIVE_REPO, build dir: $BUILD_DIR, report dir: $reportDir"

echo "Delete temps"
rm -rf $MIGRATE_DIR
Expand All @@ -50,28 +50,28 @@ echo "Translate to html"
mkdir -p $SPHINX_DIR
# sphinx-build -b html -j 4 $MIGRATE_DIR $SPHINX_DIR

echo "DUMMY FILE FOR TESTING: $DATE" > $SPHINX_DIR/test.html
echo "DUMMY FILE FOR TESTING: $date" > $SPHINX_DIR/test.html

echo "Cloning $LIVE_REPO $REPO_DIR"
git clone $LIVE_REPO $REPO_DIR

cd $REPO_DIR
echo "Checking out $GIT_LIVE_BRANCH"
git checkout $GIT_LIVE_BRANCH
echo "Checking out $redotDocsLiveBranch"
git checkout $redotDocsLiveBranch

SSH_COMMAND="ssh" # Add -v, -vv, or -vvv for verbose debugging
git config --global core.sshCommand "$SSH_COMMAND"
SSH_COMMAND="ssh -v" # Add -v, -vv, or -vvv for verbose debugging
git config core.sshCommand "$SSH_COMMAND"
echo "Using ssh command: $SSH_COMMAND"

if [ -n "$CF_PAGES" ]
then
echo "Remove Cloudflare redirect."
echo "We are on Cloudflare Pages. Setting custom ssh key and method"
# HACK: Remove annoying https redirect. I presume this was used by Cloudflare
echo "Remove Cloudflare redirect."
insteadof=`git config --list | grep insteadof`
remove=`echo $insteadof | cut -d "=" -f 1`
git config --global --unset $remove

echo "We are on Cloudflare Pages. Setting custom ssh key and method"
mkdir ~/.ssh
echo "$BUILD_SSH_KEY" > ~/.ssh/id_ed25519
echo "$BUILD_SSH_KEY_PUB" > ~/.ssh/id_ed25519.pub
Expand Down Expand Up @@ -99,9 +99,9 @@ mkdir -p $BUILD_DIR
echo "cp -r ../$SPHINX_DIR/* $BUILD_DIR"
cp -r ../$SPHINX_DIR/* $BUILD_DIR

echo "Commit and push to $GIT_LIVE_BRANCH, with message $GIT_COMMIT_MESSAGE"
echo "Commit and push to $redotDocsLiveBranch, with message $gitCommitMessage"
git add .
git commit --message "$GIT_COMMIT_MESSAGE"
git commit --message "$gitCommitMessage"
git push -vvv --force

echo "Done. Made by @Craptain"

0 comments on commit b40f2df

Please sign in to comment.