Skip to content

Publish API Docs

Publish API Docs #6

Workflow file for this run

name: Publish API Docs
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write
pages: write
id-token: write
pull-requests: 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: "api-docs"
cancel-in-progress: false
env:
DESTINATION_BRANCH: docs/${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}/${{ github.sha }}
REPOSITORY: ${{ github.event.repository.name }}
REPO: ${{ github.event.repository.owner.name }}/${{ github.event.repository.name }}
DISPLAY_NAME: Xenoglot
jobs:
synchronize-documentation:
runs-on: ubuntu-latest
name: Synchronize Repository API Documentation
steps:
- uses: actions/checkout@v4
# Grants execute permission to gradle (safety step)
- name: Grant Permissions to gradlew
run: chmod +x gradlew
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Generate API Documentation
run: ./gradlew dokkaHtmlMultiModule
- name: Relocate API Documentation Assets
run: |
mkdir -p docs/${{ env.REPOSITORY }}/documentation
cp -r build/dokka/htmlMultiModule/* docs/${{ env.REPOSITORY }}/documentation
- id: publish-docs
name: Deploy API Documentation
uses: ./.github/workflows/sync-docs/
env:
API_TOKEN_GITHUB: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
source-file: docs/${{ env.REPOSITORY }}/documentation/
destination-folder: ${{ env.REPOSITORY }}
destination-repo: teogor/source.teogor.dev
user-email: open-source@teogor.dev
user-name: Teodor Grigor
destination-branch-create: ${{ env.DESTINATION_BRANCH }}
build-and-deploy:
needs: synchronize-documentation
name: Build and Deploy Updated API Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout other repository
uses: actions/checkout@v3
with:
repository: teogor/source.teogor.dev
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Create PR (Pull Request)
run: |
json=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/teogor/source.teogor.dev/pulls \
-d '{
"title":"Updated documentation for `${{ env.REPO }}`",
"body":"## 🚀 **Updated Documentation for ${{ env.DISPLAY_NAME }}** 🚀\n\nThis pull request brings you the latest updates to the [${{ env.DISPLAY_NAME }}](https://github.com/${{ env.REPO }}) documentation, ensuring you have access to the most comprehensive and informative guide for using this powerful library.\n\n-------\n\n* Generated by [Publish Docs](https://github.com/${{ env.REPO }}/actions/workflows/publish-docs.yml)\n\n* From [${{ env.REPO }}](https://github.com/${{ env.REPO }})",
"head":"${{ env.DESTINATION_BRANCH }}",
"base":"main"
}' | jq .)
number=$(jq '.number' <<< ${json})
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/teogor/source.teogor.dev/issues/${number}/labels \
-d '{"labels":["@documentation"]}'
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/teogor/source.teogor.dev/pulls/${number}/merge \