-
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (91 loc) · 4.02 KB
/
publish-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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: [email protected]
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 \