Skip to content

Commit

Permalink
Add docs template
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryCarrade committed Nov 21, 2020
1 parent e854adf commit 3c5034a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
12 changes: 12 additions & 0 deletions workflow-templates/docs.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "Build documentation to dev.zcraft.fr/docs",
"description": "For each push to the default branch, build the documentation and push it to the website repository.",
"iconName": "octicon book",
"categories": [
"Java", "Maven"
],
"filePatterns": [
"pom.xml$"
]
}

65 changes: 65 additions & 0 deletions workflow-templates/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build documentation
on:
push:
branches: [ $default-branch ]
jobs:
javadoc:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache all the things
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build JavaDoc
run: mvn -B javadoc:javadoc --file pom.xml

- name: Checkout website repository
uses: actions/checkout@v2
with:
repository: zDevelopers/zdevelopers.github.io
path: web
branch: master
persist-credentials: false

- name: Push built documentation to website repository
shell: bash
run: |
# Extract project name
PROJECT_NAME=${GITHUB_REPOSITORY##*/}
PROJECT_NAME_LOWER=${PROJECT_NAME,,}
# Create dir if needed, cleanup old doc and copy new one
mkdir -p web/static/docs/
rm -rf web/static/docs/$PROJECT_NAME_LOWER
cp -r target/site/apidocs web/static/docs/$PROJECT_NAME_LOWER
# Go to website repository
cd web
# Configure git to push to this repository
git config --global user.name QuartzBot
git config --global user.email [email protected]
git config --global user.password ${{ secrets.QUARTZ_BOT_TOKEN }}
# Add files
echo ::group::Commit
git add .
git commit -m "Updated documentation for $PROJECT_NAME"
echo ::endgroup::
# Push
echo ::group::Push
git push https://QuartzBot:${{ secrets.QUARTZ_BOT_TOKEN }}@github.com/zDevelopers/zdevelopers.github.io.git
echo ::endgroup::

0 comments on commit 3c5034a

Please sign in to comment.