1
mirror of https://github.com/CarmJos/EasyPlugin.git synced 2024-09-19 19:25:45 +00:00
EasyPlugin/.github/workflows/deploy.yml

146 lines
4.3 KiB
YAML
Raw Normal View History

2022-01-04 12:38:29 +00:00
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
2022-01-13 08:32:36 +00:00
name: Project Deployment
2022-01-04 12:38:29 +00:00
on:
# 支持手动触发构建
workflow_dispatch:
release:
# 创建release的时候触发
types: [ published ]
jobs:
2022-05-29 20:10:54 +00:00
github-deploy:
2022-01-04 12:38:29 +00:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Set up JDK"
uses: actions/setup-java@v2
with:
java-version: '8'
2022-01-04 12:38:29 +00:00
distribution: 'adopt'
cache: maven
server-id: github
server-username: MAVEN_USERNAME
server-password: MAVEN_TOKEN
2022-01-13 08:28:47 +00:00
2022-01-13 08:38:05 +00:00
- name: "Maven Deploy"
2022-05-29 20:10:54 +00:00
run: mvn -B -Pgithub deploy --file pom.xml -DskipTests
2022-01-13 08:28:47 +00:00
env:
MAVEN_USERNAME: ${{ github.repository_owner }}
MAVEN_TOKEN: ${{secrets.GITHUB_TOKEN}}
2022-05-29 20:10:54 +00:00
local-deploy:
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: "Maven Deploy"
run: mvn -B -Plocal deploy --file pom.xml -DskipTests
- name: "Copy artifacts"
run: |
rm -rf deploy
mkdir -vp deploy
cp -vrf $HOME/local-deploy deploy/
- 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 files"
run: |
cd deploy
git init
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
2022-05-29 20:11:59 +00:00
git checkout -b repo
2022-05-29 20:10:54 +00:00
git add -A
git commit -m "Maven project deployment."
- name: "Push files"
run: |
cd deploy
git push origin HEAD:gh-pages --force
javadoc-deploy:
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
2022-01-13 08:38:05 +00:00
- name: "Copy Javadoc"
2022-01-13 08:28:47 +00:00
run: |
rm -rf docs
mkdir -vp docs
cp -vrf target/site/apidocs/* docs/
cp -vrf .documentation/javadoc/JAVADOC-README.md docs/README.md
2022-01-13 08:28:47 +00:00
2022-01-13 08:38:05 +00:00
- name: "Generate Sitemap"
2022-01-13 08:28:47 +00:00
id: sitemap
uses: cicirello/generate-sitemap@v1
with:
2022-05-29 20:10:54 +00:00
base-url-path: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
2022-01-13 08:28:47 +00:00
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
2022-05-29 20:10:54 +00:00
- name: "Configure Git"
2022-01-13 08:28:47 +00:00
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
2022-05-29 20:10:54 +00:00
git config --global user.name '${{ github.repository_owner }}'
git config --global user.email '${{ github.repository_owner }}@users.noreply.github.com'
2022-01-13 08:28:47 +00:00
2022-05-29 20:10:54 +00:00
- name: "Commit documentation"
2022-01-13 08:28:47 +00:00
run: |
cd docs
git init
2022-05-29 20:10:54 +00:00
git remote add origin git@github.com:${{ github.repository_owner }}/${{ github.event.repository.name }}.git
2022-01-13 08:28:47 +00:00
git checkout -b gh-pages
git add -A
git commit -m "API Document generated."
2022-01-13 08:38:05 +00:00
2022-05-29 20:10:54 +00:00
- name: "Push Javadoc website"
2022-01-13 08:28:47 +00:00
run: |
cd docs
git push origin HEAD:gh-pages --force