From 194d37ff03f5220e1baf7eb9d7c7ad7f3e1db30c Mon Sep 17 00:00:00 2001 From: Robert Dailey Date: Wed, 27 Apr 2022 06:34:46 -0700 Subject: [PATCH] Disable git safe repo check and optimize behavior (#10) * Disable git safe repo check and optimize behavior List of changes: - Add global config option to make our clone directory "safe". Without this, the github action fails completely due to some security features implemented in the newest version of git. - Consolidated a lot of git operations toward the bottom of the entrypoint script to avoid popping in & out of the clone directory more than needed. - Use `clone` instead of `init` + `pull` for simpler logic and automatic `origin` remote to make later operations simpler. - The final `git push` command has been simplified greatly. * Use `GH_NAME` in the clone URL. --- entrypoint.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 9c6ab44..afbee4a 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -28,17 +28,12 @@ if [ -z "$WIKI_DIR" ]; then WIKI_DIR='wiki/' fi -echo "Configuring wiki git..." -mkdir $TEMP_CLONE_FOLDER -cd $TEMP_CLONE_FOLDER -git init - -# Setup credentials -git config user.name $GH_NAME -git config user.email $GH_MAIL +# Disable Safe Repository checks +git config --global --add safe.directory "/github/workspace" +git config --global --add safe.directory "/github/workspace/$TEMP_CLONE_FOLDER" -git pull https://$GH_TOKEN@github.com/$REPO.wiki.git -cd .. +echo "Cloning wiki git..." +git clone https://$GH_NAME:$GH_TOKEN@github.com/$REPO.wiki.git $TEMP_CLONE_FOLDER # Get commit message if [ -z "$WIKI_PUSH_MESSAGE" ]; then @@ -66,6 +61,11 @@ fi echo "Pushing to Wiki" cd $TEMP_CLONE_FOLDER + +# Setup credentials +git config user.name $GH_NAME +git config user.email $GH_MAIL + git add . git commit -m "$message" -git push --set-upstream https://$GH_NAME:$GH_TOKEN@github.com/$REPO.wiki.git master || git push --set-upstream https://$GH_TOKEN@github.com/$REPO.wiki.git master +git push origin master