Skip to content

Commit

Permalink
Disable git safe repo check and optimize behavior (#10)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
rcdailey authored Apr 27, 2022
1 parent 8dc1f34 commit 194d37f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 194d37f

Please sign in to comment.