Skip to content

Commit

Permalink
CI: create action for generating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani authored and patrickelectric committed Sep 6, 2023
1 parent fe1b57a commit 6519add
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 55 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy Documentation to gh-pages

on:
push:
branches:
- master

jobs:
deploy-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

- name: Setup Python (if required)
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: sudo apt-get install doxygen graphviz

- name: Generate Documentation
run: ci/deploy-gh-pages.sh

- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/html
60 changes: 5 additions & 55 deletions ci/deploy-gh-pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,17 @@

# Deploy repository documentation

# Variables
doc_path="doc"
project_path=${doc_path}/..
clone_folder=/tmp/update-repos

repository_name="ping-python"
repository_githash=$(git -C ${project_path} rev-parse HEAD)

# Functions
source ci/ci-functions.sh

echob "Check git configuration."
if [ "${TRAVIS}" = "true" ] || ! git config --list | grep -q "user.name"; then
# Config for auto-building
echo "- Git configuration does not exist, a new one will be configured."
git config --global user.email "[email protected]"
git config --global user.name "BlueRobotics-CI"
else
echo "- Git configuration already exist."
fi
doc_path="doc"

echob "generating message api..."
test pip install jinja2
test generate/generate-python.py --output-dir=brping

echob "Build doxygen documentation."
test cd $doc_path
test doxygen Doxyfile

echo "- Check files"
ls -A "html/"

repo_path=${clone_folder}/${repository_name}
echo "- Clone ${repository_name}"
rm -rf ${repo_path}
git clone https://${GITHUB_TOKEN}@github.com/bluerobotics/${repository_name} ${repo_path}
echo "- Checkout gh-pages"
git -C ${clone_folder}/${repository_name} checkout gh-pages

echob "Update gh-pages"
mv html/* ${repo_path}

echo "- Check ${repository_name}"
if [[ $(git -C ${repo_path} diff) ]]; then
echo "- Something is different, a commit will be done."
git -C ${repo_path} add --all
COMMIT_MESSAGE="Update autogenerated files
From https://github.com/bluerobotics/ping-protocol/tree/"$repository_githash
git -C ${repo_path} commit -sm "${COMMIT_MESSAGE}"

echob "Check build type."
# Do not build pull requests
if [ ${TRAVIS_PULL_REQUEST} != "false" ]; then
echo "- Do not deploy PRs."
exit 0
fi

echob "Check branch."
# Do only build master branch
if [ ${TRAVIS_BRANCH} != "master" ]; then
echo "- Only master branch will be deployed."
exit 0
fi

git -C ${repo_path} push origin gh-pages
else
echo "- Ok."
fi

0 comments on commit 6519add

Please sign in to comment.