update deploy #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Dokka Documentation | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Java 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 | |
- name: Build Dokka | |
run: ./gradlew dokkaHtml | |
- name: Checkout docs repository | |
uses: actions/checkout@v4 | |
with: | |
repository: Pedro-Pathing/Documentation | |
token: ${{ secrets.DOCS_REPO_TOKEN }} | |
path: target-repo | |
- name: Remove old documentation | |
run: | | |
rm -rf target-repo/public/java | |
- name: Debug Dokka Output | |
run: ls -R build/dokka | |
- name: Copy documentation to target repository | |
run: | | |
mkdir -p target-repo/public/reference | |
cp -r build/dokka/html/* target-repo/public/java/ | |
- name: Check for documentation changes | |
id: check_changes | |
run: | | |
cd target-repo | |
if git diff --quiet; then | |
echo "No changes in documentation. Exiting." | |
echo "has_changes=false" >> $GITHUB_ENV | |
exit 0 | |
else | |
echo "has_changes=true" >> $GITHUB_ENV | |
fi | |
- name: Commit and push documentation | |
if: env.has_changes == 'true' | |
run: | | |
cd target-repo | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add public/reference/* | |
git commit -m "Update Dokka documentation" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.DOCS_REPO_TOKEN }} |