-
Notifications
You must be signed in to change notification settings - Fork 69
141 lines (117 loc) · 4.35 KB
/
update-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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_15.1.app
# Docs dependencies
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.3'
- 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 }}