Skip to content

Commit

Permalink
Support for main and master branch (PR #7)
Browse files Browse the repository at this point in the history
- Adds command to check master/main branch name.
- Print the name of the default branch.

Co-authored-by: Manoel Campos <[email protected]>
  • Loading branch information
HaRo87 and manoelcampos committed Dec 14, 2020
1 parent f23adc6 commit 23258c9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,23 @@ git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"


# Taking care of the fact that GitHub repos can have a default
# branch which can either be named master or main

default_branch="master"
if ! git show-branch --list $default_branch; then
default_branch="main"
fi
echo "Default branch: $default_branch"

# Avoids keeping the commit history for the gh-pages branch,
# so that such a branch keeps only the last commit.
# But this slows down the GitHub Pages website build process.
echo "Checking out the gh-pages branch without keeping its history"
git branch -D gh-pages 1>/dev/null 2>/dev/null || true
git log | head -n 1 | cut -d' ' -f2 > /tmp/commit-hash.txt
git checkout -q --orphan gh-pages master 1>/dev/null
git fetch --all
git checkout -q --orphan gh-pages $default_branch 1>/dev/null

#echo "Checking out the gh-pages branch, keeping its history"
#git checkout master -B gh-pages 1>/dev/null
Expand Down

0 comments on commit 23258c9

Please sign in to comment.