forked from PowerNukkit/PowerNukkit
-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (64 loc) · 2.63 KB
/
javadoc.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
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Update javadoc
on:
push:
branches:
- master
- bleeding
jobs:
update-javadoc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
name: Checkout main code
with:
submodules: true
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Adjust pom.xml
run: sed -i 's/-CUSTOM//g' pom.xml
- name: Generate javadoc
run: mvn --no-transfer-progress javadoc:javadoc
- name: Get version
run: |
PN_VERSION=$(mvn --no-transfer-progress help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "Version: $PN_VERSION"
echo "PN_VERSION=$PN_VERSION" >> $GITHUB_ENV
- uses: actions/checkout@v2
name: Checkout last javadoc
with:
path: javadoc
ref: javadoc
- name: Prepare the javadoc branch
run: |
cd javadoc
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout javadoc
- name: Update javadoc
run: |
rm -rf "javadoc/javadoc/$PN_VERSION"
mkdir -p "javadoc/javadoc/$PN_VERSION"
cp -a target/site/apidocs/* "javadoc/javadoc/$PN_VERSION/"
cp -a target/classes/git.properties "javadoc/javadoc/$PN_VERSION/"
- name: Add Google Analytics code snippet
run: find "javadoc/javadoc/$PN_VERSION" -type f -exec sed -ri 's/^<!-- Generated by javadoc [^-]+-->$/\<\!\-\- Global site tag \(gtag\.js\) \- Google Analytics \-\-\> \<script async src\="https\:\/\/www\.googletagmanager\.com\/gtag\/js\?id\=UA\-172727144\-3"\>\<\/script\> \<script\> window\.dataLayer \= window\.dataLayer \|\| \[\]; function gtag\(\)\{dataLayer\.push\(arguments\);\} gtag\("js", new Date\(\)\); gtag\("config", "UA\-172727144\-3"\); \<\/script\>/g' {} \;
- uses: actions/setup-node@v1
name: Install NPM
with:
node-version: 12
- name: Install sitemap-static
run: npm install -g sitemap-static
- name: Generate sitemap.xml
run: sitemap-static --pretty --prefix=https://devs.powernukkit.org/ javadoc > javadoc/sitemap.xml
- name: Commit the updated javadoc
run: |
cd javadoc
git config --local user.email "[email protected]"
git config --local user.name "PowerNukkit Bot"
git add sitemap.xml
git add -A "javadoc/$PN_VERSION"
git commit -m "Update javadoc version $PN_VERSION"
git push