-
Notifications
You must be signed in to change notification settings - Fork 16
126 lines (108 loc) · 4.3 KB
/
docs.yml
File metadata and controls
126 lines (108 loc) · 4.3 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Publish docs
on:
workflow_dispatch:
push:
branches:
- main
release:
types:
- released
# 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
defaults:
run:
shell: bash
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
id-token: write
pull-requests: write
jobs:
docs:
runs-on: ubuntu-latest
name: Build/publish Docs
if: github.repository == 'docling-project/docling-java'
steps:
- name: Checkout sources
if: github.event_name != 'release'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
path: app
- name: Get release sources
if: github.event_name == 'release'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
ref: ${{ github.event.release.tag_name }}
path: app
- name: Setup env (release)
if: github.event_name == 'release'
working-directory: app
run: |
echo "DOCS_ALIAS=current" >> $GITHUB_ENV
echo "DOCS_VERSION=$(yq '.release.previous-version' .github/project.yml)" >> $GITHUB_ENV
- name: Setup env (other)
if: (github.event_name != 'release')
working-directory: app
run: |
echo "DOCS_ALIAS=dev" >> $GITHUB_ENV
echo "DOCS_VERSION=$(yq '.release.current-version' .github/project.yml)" >> $GITHUB_ENV
- name: Get docs
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: gh-pages
path: docs
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
- name: Setup Java 21
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 21
distribution: temurin
- name: Setup Gradle
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
- name: Show current docs
run: |
tree ${{ github.workspace }}/docs
cat ${{ github.workspace }}/docs/versions.json
- name: Generate documentation
working-directory: app
run: |
./gradlew --console=plain :docs:build \
-Pversion=${{ env.DOCS_VERSION }} \
-Pdocs.alias=${{ env.DOCS_ALIAS }} \
-Pdocs.versionsFile=${{ github.workspace }}/docs/versions.json
- name: Copy to gh-pages
run: cp -Rf app/docs/build/mkdocs/* docs/
- uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: app-token
with:
app-id: ${{ vars.DOCLING_JAVA_CI_APP_ID }}
private-key: ${{ secrets.DOCLING_JAVA_CI_PRIVATE_KEY }}
- name: Create PR
id: create-pr
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
token: ${{ steps.app-token.outputs.token }}
path: docs
commit-message: "docs: Build and publish docs (from ${{ github.workflow }} run # ${{ github.run_number }})"
branch: build-docs/sourceref
branch-suffix: short-commit-hash
delete-branch: true
base: gh-pages
signoff: true
sign-commits: true
title: "docs: Build and publish docs (from ${{ github.workflow }} run # ${{ github.run_number }})"
body: "docs: Build and publish docs from [${{ github.workflow }} run # ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}), which was triggered by commit ${{ env.REF }}."
labels: documentation
- name: Merge PR
if: (steps.create-pr.outputs.pull-request-operation == 'created') && steps.create-pr.outputs.pull-request-number
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: gh pr merge --merge --admin --delete-branch "${{ steps.create-pr.outputs.pull-request-url }}"