Skip to content

Publish Documentation Site #67

Publish Documentation Site

Publish Documentation Site #67

Workflow file for this run

name: Publish Documentation Site
on:
workflow_dispatch:
inputs:
main-ref:
description: 'Main Workflow repo ref to publish'
default: 'main'
required: true
kotlin-ref:
description: 'Kotlin Git ref to publish'
default: 'main'
required: true
swift-ref:
description: 'Swift Git ref to publish'
default: 'main'
required: true
docs-branch:
description: 'Branch name for updated documentation to be published'
required: true
jobs:
build-docs:
runs-on: macos-latest
steps:
- name: Check out main repo
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.main-ref }}
path: 'workflow'
- name: Check out Kotlin repo
uses: actions/checkout@v3
with:
repository: 'square/workflow-kotlin'
ref: ${{ github.event.inputs.kotlin-ref }}
path: 'workflow-kotlin'
- name: Check out Swift repo
uses: actions/checkout@v3
with:
repository: 'square/workflow-swift'
ref: ${{ github.event.inputs.swift-ref }}
path: 'workflow-swift'
# Ruby Gems
- name: Load gem cache
uses: actions/cache@v3
with:
path: workflow-swift/.bundle
key: gems-${{ hashFiles('workflow-swift/Gemfile.lock') }}
- name: Set up Swift environment
run: |
# Set global bundle path so it gets used by build_swift_docs.sh running in the nested repo as well.
cd workflow-swift
bundle config --global path "$(pwd)/.bundle"
bundle check || bundle install
# Don't need to run pod gen, the website script does that itself.
brew install sourcedocs
# Use Xcode
sudo xcode-select -s /Applications/Xcode_14.2.0.app
# Docs dependencies
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10.10'
- name: Install Python dependencies
run: |
cd workflow
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 17
# Build Swift docs
- name: Build Swift docs
run: |
mkdir -p workflow/docs/swift/api
cd workflow-swift
bundle exec pod gen Development.podspec
cd gen/Development
sourcedocs generate --output-folder "../../../workflow/docs/swift/api/Workflow" -- -scheme Workflow -workspace Development.xcworkspace
sourcedocs generate --output-folder "../../../workflow/docs/swift/api/WorkflowUI" -- -scheme WorkflowUI -workspace Development.xcworkspace
sourcedocs generate --output-folder "../../../workflow/docs/swift/api/WorkflowTesting" -- -scheme WorkflowTesting -workspace Development.xcworkspace
sourcedocs generate --output-folder "../../../workflow/docs/swift/api/WorkflowReactiveSwift" -- -scheme WorkflowReactiveSwift -workspace Development.xcworkspace
# Build Kotlin docs
- name: Build Kotlin docs
run: |
cd workflow-kotlin
./gradlew assemble --build-cache --quiet
./gradlew siteDokka --build-cache --quiet
mkdir -p ../workflow/docs/kotlin/api
mv build/dokka/htmlMultiModule ../workflow/docs/kotlin/api
# Generate the mkdocs site
- name: Generate site with mkdocs
env:
WORKFLOW_GOOGLE_ANALYTICS_KEY: ${{ secrets.WORKFLOW_GOOGLE_ANALYTICS_KEY }}
run: |
cd workflow
echo "Building documentation site"
mkdocs build
# Push docs to new branch
- name: Create new docs branch
uses: actions/checkout@v3
with:
ref: gh-pages
path: 'workflow-publish'
- name: Commit updated docs
run: |
# Get the source repo SHAs
KOTLIN_REF=$(git --git-dir workflow-kotlin/.git log -1 --format='%H')
SWIFT_REF=$(git --git-dir workflow-swift/.git log -1 --format='%H')
cd workflow-publish
git checkout -b ${{ github.event.inputs.docs-branch }}
# Copy all the files over from the 'site' directory
cp -R ../workflow/site/* .
# Commit and push
git add .
git commit -m "Update documentation" -m "Docs built from square/workflow-kotlin@$KOTLIN_REF and square/workflow-swift@$SWIFT_REF"
git push origin HEAD:${{ github.event.inputs.docs-branch }}