-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (72 loc) · 2.69 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
88 lines (72 loc) · 2.69 KB
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
name: Deploy DocC documentation
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: macos-15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Build DocC archive
run: |
xcodebuild docbuild \
-project "Movie Poster/Movie Poster.xcodeproj" \
-scheme "Movie Poster" \
-destination 'generic/platform=iOS' \
-derivedDataPath "$RUNNER_TEMP/DerivedData" \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
IPHONEOS_DEPLOYMENT_TARGET=26.2
- name: Convert DocC archive for static hosting
env:
# GitHub Pages serves a project site at https://<owner>.github.io/<repo>/,
# so the hosting base path must be exactly the repository name.
BASE_PATH: ${{ github.event.repository.name }}
run: |
echo "hosting base path: $BASE_PATH"
ARCHIVE=$(find "$RUNNER_TEMP/DerivedData/Build/Products" -name '*.doccarchive' -print -quit)
test -n "$ARCHIVE"
xcrun docc process-archive transform-for-static-hosting "$ARCHIVE" \
--hosting-base-path "$BASE_PATH" \
--output-path "$RUNNER_TEMP/docs"
# Work around swiftlang/swift-docc#170: `transform-for-static-hosting`
# rewrites every nested index.html to use --hosting-base-path but leaves
# the ROOT index.html pointing at "/" (var baseUrl = "/", /js, /css),
# which 404s on a project Pages site and shows a blank page.
# Patch the root index.html to match the nested ones.
ROOT_INDEX="$RUNNER_TEMP/docs/index.html"
sed -i '' \
-e 's|var baseUrl = "/"|var baseUrl = "/'"$BASE_PATH"'/"|g' \
-e 's|href="/favicon|href="/'"$BASE_PATH"'/favicon|g' \
-e 's|src="/js/|src="/'"$BASE_PATH"'/js/|g' \
-e 's|href="/css/|href="/'"$BASE_PATH"'/css/|g' \
"$ROOT_INDEX"
echo "patched root index.html:"
grep -oE 'baseUrl = "[^"]*"|(src|href)="/[^"]+"' "$ROOT_INDEX"
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ runner.temp }}/docs
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4