From 4b594269bdca53a63d8ef735548a42d6cead0ab5 Mon Sep 17 00:00:00 2001 From: CarmJos Date: Sat, 28 May 2022 12:30:04 +0800 Subject: [PATCH] =?UTF-8?q?ci(javadoc):=20=E6=B7=BB=E5=8A=A0Javadoc?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=83=A8=E7=BD=B2=E5=88=B0gh-pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .documentation/javadoc/JAVADOC-README.md | 9 ++++ .github/workflows/deploy.yml | 64 +++++++++++++++++++++++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .documentation/javadoc/JAVADOC-README.md diff --git a/.documentation/javadoc/JAVADOC-README.md b/.documentation/javadoc/JAVADOC-README.md new file mode 100644 index 00000000..cb736c47 --- /dev/null +++ b/.documentation/javadoc/JAVADOC-README.md @@ -0,0 +1,9 @@ +# MineConfiguration Javadoc + +基于 [Github Pages](https://pages.github.com/) 搭建,请访问 [JavaDoc](https://carmjos.github.io/MineConfiguration) 。 + +## 如何实现? + +若您也想通过 [Github Actions](https://docs.github.com/en/actions/learn-github-actions) +自动部署项目的Javadoc到 [Github Pages](https://pages.github.com/) , +可以参考我的文章 [《自动部署Javadoc到Github Pages》](https://pages.carm.cc/doc/javadoc-in-github.html) 。 \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bdf7f72a..5cdc169c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -58,4 +58,66 @@ jobs: env: MAVEN_USERNAME: ${{ secrets.OSSRH_USER }} MAVEN_PASSWORD: ${{ secrets.OSSRH_PASS }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} \ No newline at end of file + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} + + javadoc-deploy: + name: "Deploy Javadoc (Github Pages)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: "Set up JDK" + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + cache: maven + + - name: "Generate Javadoc" + run: mvn -B javadoc:aggregate --file pom.xml -DskipTests + + - name: "Copy Javadoc" + run: | + rm -rf docs + mkdir -vp docs + cp -vrf target/site/apidocs/* docs/ + cp -vrf .documentation/javadoc/JAVADOC-README.md docs/README.md + + - name: "Generate Sitemap" + id: sitemap + uses: cicirello/generate-sitemap@v1 + with: + base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }} + path-to-root: docs + + - name: Output stats + run: | + echo "sitemap-path = ${{ steps.sitemap.outputs.sitemap-path }}" + echo "url-count = ${{ steps.sitemap.outputs.url-count }}" + echo "excluded-count = ${{ steps.sitemap.outputs.excluded-count }}" + ls -l docs + + - name: Configure Git + env: + DEPLOY_PRI: ${{secrets.DEPLOY_PRI}} + run: | + sudo timedatectl set-timezone "Asia/Shanghai" + mkdir -p ~/.ssh/ + echo "$DEPLOY_PRI" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan github.com >> ~/.ssh/known_hosts + git config --global user.name '${{ github.repository_owner }}' + git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com' + + - name: Commit documentation changes + run: | + cd docs + git init + git remote add origin ${{ github.repositoryUrl }} + git checkout -b gh-pages + git add -A + git commit -m "API Document generated." + + - name: Javadoc Website Push + run: | + cd docs + git push origin HEAD:gh-pages --force \ No newline at end of file