Skip to content

Commit

Permalink
Merge pull request #9 from teogor/plugin/winds
Browse files Browse the repository at this point in the history
Enhance plugin configuration for Winds integration
teogor authored Nov 21, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 62cbb00 + 3a2deaf commit 9e2b2d9
Showing 79 changed files with 1,037 additions and 699 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Publish API Docs

on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: write
pages: write
id-token: write
pull-requests: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "api-docs"
cancel-in-progress: false

env:
OWNER: teogor
DESTINATION_BRANCH: docs/teogor/${{ github.event.repository.name }}/${{ github.sha }}
REPOSITORY: ${{ github.event.repository.name }}
REPO: teogor/${{ github.event.repository.name }}
DISPLAY_NAME: Drifter

jobs:
synchronize-documentation:
runs-on: ubuntu-latest
name: Synchronize Repository API Documentation
steps:
- uses: actions/checkout@v4

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

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

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

- name: Relocate API Documentation Assets
run: |
mkdir -p docs/${{ env.REPOSITORY }}/documentation
cp -r build/dokka/htmlMultiModule/* docs/${{ env.REPOSITORY }}/documentation
- id: publish-docs
name: Deploy API Documentation
uses: ./.github/workflows/sync-docs/
env:
API_TOKEN_GITHUB: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
source-file: docs/${{ env.REPOSITORY }}/documentation/
destination-folder: ${{ env.REPOSITORY }}
destination-repo: teogor/source.teogor.dev
user-email: [email protected]
user-name: Teodor Grigor
destination-branch-create: ${{ env.DESTINATION_BRANCH }}

build-and-deploy:
needs: synchronize-documentation
name: Build and Deploy Updated API Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout other repository
uses: actions/checkout@v3
with:
repository: teogor/source.teogor.dev
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

- name: Create PR (Pull Request)
run: |
json=$(curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/teogor/source.teogor.dev/pulls \
-d '{
"title":"Updated documentation for `${{ env.REPO }}`",
"body":"## 🚀 **Updated Documentation for ${{ env.DISPLAY_NAME }}** 🚀\n\nThis pull request brings you the latest updates to the [${{ env.DISPLAY_NAME }}](https://github.com/${{ env.REPO }}) documentation, ensuring you have access to the most comprehensive and informative guide for using this powerful library.\n\n-------\n\n* Generated by [Publish Docs](https://github.com/${{ env.REPO }}/actions/workflows/publish-docs.yml)\n\n* From [${{ env.REPO }}](https://github.com/${{ env.REPO }})",
"head":"${{ env.DESTINATION_BRANCH }}",
"base":"main"
}' | jq .)
number=$(jq '.number' <<< ${json})
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/teogor/source.teogor.dev/issues/${number}/labels \
-d '{"labels":["@documentation"]}'
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.PERSONAL_ACCESS_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/teogor/source.teogor.dev/pulls/${number}/merge \
65 changes: 65 additions & 0 deletions .github/workflows/sync-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Publish Docs'
description: 'Comprehensive publish docs'
branding:
icon: 'git-commit'
color: 'red'
inputs:
source-file:
description: 'Source file from the origin directory'
required: true
destination-repo:
description: 'Destination repository'
required: true
destination-folder:
description: 'Directory to push the file to'
required: false
user-email:
description: 'Email for the git commit'
required: true
user-name:
description: 'GitHub username for the commit'
required: true
destination-branch:
description: 'branch to push file to, defaults to main'
required: false
destination-branch-create:
description: 'Destination branch to create for this commit'
required: false
commit-message:
description: 'A custom message for the commit'
required: false
rename:
description: 'Rename the destination file'
required: false
use-rsync:
description: 'Copy files/directories using rsync instead of cp. Experimental feature, please know your use case'
required: false
git-server:
description: 'Git server host, default github.com'
required: false
default: github.com
runs:
using: "composite"
steps:
- name: Make all .sh files executable
run: find . -type f -name "*.sh" -exec chmod +x {} \;
shell: bash

- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash

- name: Execute Entrypoint Script
shell: bash
env:
SOURCE_FILE: ${{ inputs.source-file }}
DESTINATION_REPO: ${{ inputs.destination-repo }}
DESTINATION_FOLDER: ${{ inputs.destination-folder }}
USER_EMAIL: ${{ inputs.user-email }}
USER_NAME: ${{ inputs.user-name }}
DESTINATION_BRANCH: ${{ inputs.destination-branch }}
DESTINATION_BRANCH_CREATE: ${{ inputs.destination-branch-create }}
COMMIT_MESSAGE: ${{ inputs.commit-message }}
GIT_SERVER: ${{ inputs.git-server }}
RENAME: ${{ inputs.rename }}
USE_RSYNC: ${{ inputs.use-rsync }}
run: sync-files.sh
85 changes: 85 additions & 0 deletions .github/workflows/sync-docs/sync-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/sh

set -e
set -x

# Validate required input
if [ -z "$SOURCE_FILE" ]; then
echo "Error: Source file must be specified."
exit 1
fi

# Set default values for optional variables
if [ -z "$GIT_SERVER" ]; then
GIT_SERVER="github.com"
fi

if [ -z "$DESTINATION_BRANCH" ]; then
DESTINATION_BRANCH="main"
fi

# Clone the destination Git repository
OUTPUT_BRANCH="$DESTINATION_BRANCH"

CLONE_DIR=$(mktemp -d)
echo "Cloning destination Git repository: $DESTINATION_REPO"

git config --global user.email "$USER_EMAIL"
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"

if [ ! -z "$RENAME" ]; then
echo "Renaming file to: ${RENAME}"
DEST_COPY="$CLONE_DIR/$DESTINATION_FOLDER/$RENAME"
fi

# Delete the previous folder if it exists
if [ -d "$DEST_COPY" ]; then
echo "Deleting existing folder: $DEST_COPY"
rm -rf "$DEST_COPY"
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

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

if [ ! -z "$DESTINATION_BRANCH_CREATE" ]; then
echo "Creating new branch: $DESTINATION_BRANCH_CREATE"
git checkout -b "$DESTINATION_BRANCH_CREATE"
OUTPUT_BRANCH="$DESTINATION_BRANCH_CREATE"
fi

if [ -z "$COMMIT_MESSAGE" ]; then
COMMIT_MESSAGE="Automated updates based on https://$GIT_SERVER/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
fi

# Add the copied file to the staging area
echo "Adding git commit"
git add .

# Commit changes if there are any
if git status | grep -q "Changes to be committed"; then
echo "Committing changes with message: $COMMIT_MESSAGE"
git commit --message "$COMMIT_MESSAGE"

echo "Pushing git commit to branch: $OUTPUT_BRANCH"
git push -u origin HEAD:"$OUTPUT_BRANCH"
else
echo "No changes detected, skipping commit and push"
fi
45 changes: 45 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9e2b2d9

Please sign in to comment.