Skip to content

Commit 99605c4

Browse files
authored
MOB-6046: GHA gh-pages permissions (#8)
fix file formatting, switch to use secrets.GITHUB_TOKEN rather than secrets.DEVOPS_PAT, and add read permissions to the step too
1 parent d8ad246 commit 99605c4

File tree

1 file changed

+48
-45
lines changed

1 file changed

+48
-45
lines changed

.github/workflows/build-docs.yml

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,60 +23,63 @@ jobs:
2323
needs: build-jekyll
2424
runs-on: macos-13
2525
timeout-minutes: 10
26+
permissions: read-all
2627
steps:
27-
- uses: actions/checkout@v4
28-
with:
29-
lfs: 'true'
30-
- name: Download Jekyll Artifact
31-
uses: actions/download-artifact@v3
32-
with:
33-
name: jekyll-site
34-
path: _site
28+
- uses: actions/checkout@v4
29+
with:
30+
lfs: 'true'
31+
- name: Download Jekyll Artifact
32+
uses: actions/download-artifact@v3
33+
with:
34+
name: jekyll-site
35+
path: _site
3536

36-
- name: Select Xcode
37-
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
37+
- name: Select Xcode
38+
run: sudo xcode-select -s /Applications/Xcode_15.0.1.app
3839

39-
- name: Generate DocC docs
40-
run: |
41-
SCHEME="HVCaptureSDK"
40+
- name: Generate DocC docs
41+
run: |
42+
SCHEME="HVCaptureSDK"
4243
43-
# have derivedData outside of project dir to avoid SPM cache issue? https://forums.swift.org/t/xcode-and-swift-package-manager/44704/5
44-
TMP_BUILDIR="$HOME/doc-build"
45-
mkdir -p ${TMP_BUILDIR}
46-
DOCARCHIVE_DIR="tmp/docs"
47-
mkdir -p ${DOCARCHIVE_DIR}
48-
PAGE_DIR="tmp/site"
49-
mkdir -p ${PAGE_DIR}
44+
# have derivedData outside of project dir to avoid SPM cache issue? https://forums.swift.org/t/xcode-and-swift-package-manager/44704/5
45+
TMP_BUILDIR="$HOME/doc-build"
46+
mkdir -p ${TMP_BUILDIR}
47+
DOCARCHIVE_DIR="tmp/docs"
48+
mkdir -p ${DOCARCHIVE_DIR}
49+
PAGE_DIR="tmp/site"
50+
mkdir -p ${PAGE_DIR}
5051
51-
touch $HOME/.netrc
52-
echo "machine api.github.com login hover-devops password ${{ secrets.DEVOPS_PAT }}" > $HOME/.netrc
52+
touch $HOME/.netrc
53+
echo "machine api.github.com" > $HOME/.netrc
54+
echo "login ${{ secrets.GITHUB_TOKEN }}" >> $HOME/.netrc
55+
echo "password ${{ secrets.GITHUB_TOKEN }}" >> $HOME/.netrc
5356
54-
# compile the DocC archive(s)
55-
xcodebuild docbuild \
56-
-scheme "${SCHEME}" \
57-
-destination generic/platform=iOS \
58-
-derivedDataPath "${TMP_BUILDIR}"
59-
# collect the generated docarchive(s)
60-
cp -R $(find ${TMP_BUILDIR} -type d -name "*.doccarchive") "${DOCARCHIVE_DIR}/."
61-
# NOTE: this command seems to wipe out the path specified by --output-path, so use a tmp dir that you don't mind getting deleted (i.e. don't use _site as the output directory directly)
62-
$(xcrun --find docc) process-archive transform-for-static-hosting "${DOCARCHIVE_DIR}/${SCHEME}.doccarchive" --hosting-base-path "hover-capture-ios" --output-path "${PAGE_DIR}"
57+
# compile the DocC archive(s)
58+
xcodebuild docbuild \
59+
-scheme "${SCHEME}" \
60+
-destination generic/platform=iOS \
61+
-derivedDataPath "${TMP_BUILDIR}"
62+
# collect the generated docarchive(s)
63+
cp -R $(find ${TMP_BUILDIR} -type d -name "*.doccarchive") "${DOCARCHIVE_DIR}/."
64+
# NOTE: this command seems to wipe out the path specified by --output-path, so use a tmp dir that you don't mind getting deleted (i.e. don't use _site as the output directory directly)
65+
$(xcrun --find docc) process-archive transform-for-static-hosting "${DOCARCHIVE_DIR}/${SCHEME}.doccarchive" --hosting-base-path "hover-capture-ios" --output-path "${PAGE_DIR}"
6366
64-
# Copy DocC Output to Jekyll Site
65-
mkdir -p _site/
66-
# get rid of the DocC index.html, since it's an empty page anyways and we don't want to overwrite the Jekyll one
67-
rm "${PAGE_DIR}"/index.html
68-
cp -R "${PAGE_DIR}"/* _site/.
69-
rm -rf "${TMP_BUILDIR}"
67+
# Copy DocC Output to Jekyll Site
68+
mkdir -p _site/
69+
# get rid of the DocC index.html, since it's an empty page anyways and we don't want to overwrite the Jekyll one
70+
rm "${PAGE_DIR}"/index.html
71+
cp -R "${PAGE_DIR}"/* _site/.
72+
rm -rf "${TMP_BUILDIR}"
7073
71-
- name: Fix GH-pages permissions
72-
run: |
73-
# from https://github.com/actions/upload-pages-artifact
74-
chmod -v -R +rX "_site/" | while read line; do
75-
echo "::warning title=Invalid file permissions automatically fixed::$line"
76-
done
74+
- name: Fix GH-pages permissions
75+
run: |
76+
# from https://github.com/actions/upload-pages-artifact
77+
chmod -v -R +rX "_site/" | while read line; do
78+
echo "::warning title=Invalid file permissions automatically fixed::$line"
79+
done
7780
78-
- name: Upload Pages artifact
79-
uses: actions/upload-pages-artifact@v2
81+
- name: Upload Pages artifact
82+
uses: actions/upload-pages-artifact@v2
8083

8184
# Deploy github pages job
8285
deploy:

0 commit comments

Comments
 (0)