-
-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (99 loc) · 3.16 KB
/
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
107
108
109
110
111
112
113
114
115
116
117
name: docs
on:
workflow_call:
inputs:
project:
description: 'Project to run the command to.'
type: string
required: true
version:
description: 'Version to rewrite in gradle.properties.'
type: string
required: true
permissions:
contents: write
pages: write
id-token: write
env:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-XX:MaxMetaspaceSize=4g"
JDK_VERSION: 19
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK ${{ env.JDK_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JDK_VERSION }}
distribution: temurin
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3
- name: Replace version on project gradle.properties
run: |
cd ${{ inputs.project }}
sed -i "/^VERSION=/ s/=.*/=${{ inputs.version }}/" gradle.properties
- name: remove SNAPSHOT on root gradle.properties
run: sed -i '/^VERSION=/ s/-SNAPSHOT//' gradle.properties
- name: Dokka build
uses: gradle/gradle-build-action@v2
with:
arguments: ${{ inputs.project }}:dokkaHtml
- name: Remove snapshot versions on generated docs
run: |
cd ./docs/api/${{ inputs.project }}
rm -rf ${{ inputs.version }}/older/*-SNAPSHOT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docs
path: ./docs/api/${{ inputs.project }}/${{ inputs.version }}
if-no-files-found: error
push:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Remove previous versions
run: |
cd ./docs/api/${{ inputs.project }}
rm -rf *
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: docs
path: ./docs/api/${{ inputs.project }}/${{ inputs.version }}
- name: Commit latest docs
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -f docs/api/${{ inputs.project }}
git commit -m "docs(api): ${{ inputs.project }} v${{ inputs.version }} [skip-ci]"
- name: Push to repository
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: ./docs/api/${{ inputs.project }}
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
deployments: write
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: docs
path: ./docs/api
- name: Publish to cloudflare pages
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ inputs.project }}
directory: docs/api/
gitHubToken: ${{ secrets.GITHUB_TOKEN }}