[build] fix deployment of documentation #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Master | |
on: | |
push: | |
branches: | |
- master | |
- build/test-deployment-of-versions | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
build: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: "gradle" | |
- name: Build | |
run: ./gradlew build | |
- name: Build documentation | |
run: ./gradlew dokkaHtml | |
- name: Set env.VERSION from json | |
run: | | |
echo "VERSION=$(cat ./build/dokka/html/version.json | jq -r '.version')" >> "$GITHUB_ENV" | |
- uses: actions/configure-pages@v3 | |
if: ${{ !contains(env.VERSION, '-SNAPSHOT') }} | |
- uses: actions/upload-pages-artifact@v1 | |
if: ${{ !contains(env.VERSION, '-SNAPSHOT') }} | |
with: | |
path: 'build/dokka/html' | |
- uses: actions/deploy-pages@v2 | |
if: ${{ !contains(env.VERSION, '-SNAPSHOT') }} | |
id: deployment | |
- name: Cleanup, archive and commit documenation | |
if: ${{ !contains(env.VERSION, '-SNAPSHOT') }} | |
run: | | |
rm -Rf ./build/dokka/html/older | |
# Archive documentation | |
rm -Rf "./documentation/${{env.VERSION}}" | |
mv ./build/dokka/html "./documentation/${{env.VERSION}}" | |
rm -Rf ./documentation/*-SNAPSHOT | |
# Commit documentation | |
## setup the username and email | |
git config user.name "GitHub Actions" | |
git config user.email "<>" | |
## Stage the file, commit and push | |
git add documentation | |
git commit -m "[ci-commit] [documentation] updated documentation for ${{env.VERSION}}" || true | |
git push origin master |