Skip to content

Commit

Permalink
Merge pull request #5 from teogor/docs/deployment
Browse files Browse the repository at this point in the history
Introduce MkDocs for documentation generation
  • Loading branch information
teogor authored Nov 22, 2023
2 parents ff798bb + af25881 commit a775424
Show file tree
Hide file tree
Showing 20 changed files with 767 additions and 566 deletions.
41 changes: 34 additions & 7 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,51 @@ env:
jobs:
synchronize-documentation:
runs-on: ubuntu-latest
name: Synchronize Repository API Documentation
name: Synchronize Repository Documentation
steps:
- uses: actions/checkout@v4

# Grants execute permission to gradle (safety step)
- name: Grant Permissions to gradlew
run: chmod +x gradlew

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs-material
pip install mkdocs-material[recommended,git,imaging]
- name: Build MkDocs
run: |
mkdocs build --clean
mkdocs --version
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Generate API Documentation
run: ./gradlew dokkaHtmlMultiModule
run: ./gradlew -D'org.gradle.unsafe.configuration-cache=false' dokkaHtmlMultiModule

- name: Relocate API Documentation Assets
- name: Relocate API References
run: |
mkdir -p docs/${{ env.REPOSITORY }}/documentation
cp -r build/dokka/htmlMultiModule/* docs/${{ env.REPOSITORY }}/documentation
mkdir -p build/docs/${{ env.REPOSITORY }}/reference
cp -r build/dokka/htmlMultiModule/* build/docs/${{ env.REPOSITORY }}/reference
- id: publish-docs
name: Deploy API Documentation
name: Deploy Documentation
uses: ./.github/workflows/sync-docs/
env:
API_TOKEN_GITHUB: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
source-file: docs/${{ env.REPOSITORY }}/documentation/
source-file: build/docs/${{ env.REPOSITORY }}/
destination-folder: ${{ env.REPOSITORY }}
destination-repo: teogor/source.teogor.dev
user-email: [email protected]
Expand All @@ -73,6 +89,17 @@ jobs:
with:
repository: teogor/source.teogor.dev
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
ref: ${{ env.DESTINATION_BRANCH || 'main' }}
# This is important to fetch the changes to the previous commit
fetch-depth: 0

# - name: Prettify code
# uses: creyD/[email protected]
# with:
# # This part is also where you can pass other options, for example:
# prettier_options: --write ${{ env.REPOSITORY }}/**/*.{js,html,css,json}
# only_changed: False
# same_commit: True

- name: Create PR (Pull Request)
run: |
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/sync-docs/sync-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ git config --global user.name "$USER_NAME"
git clone --single-branch --branch $DESTINATION_BRANCH "https://x-access-token:$API_TOKEN_GITHUB@$GIT_SERVER/$DESTINATION_REPO.git" "$CLONE_DIR"

# Determine the destination file path
DEST_COPY="$CLONE_DIR/$DESTINATION_FOLDER"
DEST_COPY="$CLONE_DIR/$DESTINATION_FOLDER/"

if [ ! -z "$RENAME" ]; then
echo "Renaming file to: ${RENAME}"
Expand All @@ -46,15 +46,8 @@ fi
# Copy the source file to the destination repository
echo "Copying contents to Git repo: $SOURCE_FILE"

mkdir -p $CLONE_DIR/$DESTINATION_FOLDER

if [ -z "$USE_RSYNC" ]; then
echo "Copying using cp"
cp -R "$SOURCE_FILE" "$DEST_COPY"
else
echo "Copying using rsync"
rsync -avrh "$SOURCE_FILE" "$DEST_COPY"
fi
# Move the source file instead of copying it to avoid creating duplicates
cp -r "$SOURCE_FILE" "$DEST_COPY"

# Check out the specified branch or create a new one
cd "$CLONE_DIR"
Expand Down
Loading

0 comments on commit a775424

Please sign in to comment.