Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,15 @@ pages that are hosted by GitHub and can easily be published via
GitHub. You can post the website for your Maven projects by first
creating a `gh-pages` branch (from the initial revision of the
repository), removing the `README.md` file on that branch (because
it will take precedence over the generated `index.html` file) and
pushing it to GitHub:
it will take precedence over the generated `index.html` file),
removing `*.zip` from `.gitignore` (because the Maven process will add
.zip files to the `gh-pages` branch) and pushing it to GitHub:

```
$ git checkout 62fc42c5b0cf4ddddf78e7568b008bedc9037b38
$ git branch gh-pages
$ git rm README.md
$ git add .gitignore
$ git commit -m "Remove README.md on gh-pages branch" README.md
$ git push --set-upstream origin gh-pages
$ git checkout main
Expand Down
45 changes: 45 additions & 0 deletions gh-pages-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

setup_gh_branch() {
if git show-ref -q --heads "gh-pages"; then # check if gh-pages branch exists
git checkout gh-pages # checkout existing branch
else
echo "** Creating new branch: gh-pages **"
git checkout -b gh-pages # create gh-pages and checkout
fi

update_files # update files in gh-pages branch
git checkout main # checkout main branch

}

update_files() {
has_change=0 # files were modified bool
if [ -f README.md ]; then # check if root level readme exists
echo "** Removing README.md **"
rm README.md; # delete root level readme
git add README.md # stage delete in git
has_change=1
fi

if [ ! -z $(grep "*.zip" .gitignore) ]; then # check if *.zip is present in .gitignore
echo "** Removing *.zip from .gitignore"
sed -i /"*.zip"/d .gitignore; # remove the *.zip line from .gitignore
git add .gitignore # stage .gitignore modifications in git
has_change=1
fi

if [ $has_change -eq 1 ]; then # if files were modified, commit changes
echo "** Committing updates to git **"
git commit -m "REMOVE README.md and update .gitignore on gh-pages branch"
fi
}

deploy_gh_pages() {
setup_gh_branch # prep gh-pages branch for site deployment
./mvnw site # create site files
./mvnw site:stage # gather site files across projects
./mvnw scm-publish:publish-scm # upload site files to gh-pages branch
}

deploy_gh_pages