Skip to content

Commit 3e01099

Browse files
authored
Merge pull request #5031 from platformsh/feat-internal-api
Add Api doc on P.sh side + Internal API Docs on both
2 parents 733171c + 6df3309 commit 3e01099

File tree

2 files changed

+57
-5
lines changed

2 files changed

+57
-5
lines changed

.github/workflows/check-openapi-spec-update.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
git config --global user.name "github-actions[bot]"
2424
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2525
26-
- name: Download redoc_static.html from GitLab
26+
- name: Download redoc_static.html and redoc-static-internal.html from GitLab
2727
env:
2828
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
2929
run: |
@@ -48,6 +48,18 @@ jobs:
4848
--output shared/pages/openapispec-upsun.yaml \
4949
"https://lab.plat.farm/api/v4/projects/${PROJECT_ENCODED}/repository/files/$(python3 -c "import urllib.parse; print(urllib.parse.quote('web/openapispec-upsun.yaml',safe=''))")/raw?ref=${REF}"
5050
51+
# @todo should we also copy over the stylesheet? or should the version in docs be canonical?
52+
curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
53+
--output shared/pages/api-internal.html \
54+
"https://lab.plat.farm/api/v4/projects/${PROJECT_ENCODED}/repository/files/$(python3 -c "import urllib.parse; print(urllib.parse.quote('web/redoc-static-internal.html',safe=''))")/raw?ref=${REF}"
55+
# @todo let's refactor this to be more concise. maybe just retrieve everything in the directory?
56+
curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
57+
--output shared/pages/openapispec-upsun-internal.json \
58+
"https://lab.plat.farm/api/v4/projects/${PROJECT_ENCODED}/repository/files/$(python3 -c "import urllib.parse; print(urllib.parse.quote('web/openapispec-upsun-internal.json',safe=''))")/raw?ref=${REF}"
59+
# @todo see above
60+
curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \
61+
--output shared/pages/openapispec-upsun-internal.yaml \
62+
"https://lab.plat.farm/api/v4/projects/${PROJECT_ENCODED}/repository/files/$(python3 -c "import urllib.parse; print(urllib.parse.quote('web/openapispec-upsun-internal.yaml',safe=''))")/raw?ref=${REF}"
5163
5264
- name: Create Pull Request if changes
5365
uses: peter-evans/create-pull-request@v6

.platform/applications.yaml

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,27 @@
2424
# Build hooks can modify the application files on disk but not access any services like databases.
2525
build: |
2626
set -e
27-
mkdir -p "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/"
28-
# add yet another fall back redirect in case all the others fail
29-
echo '<html><head><meta http-equiv="refresh" content="0; url=https://docs.upsun.com/api/"></head>' > "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/index.html"
30-
echo '<body><p>API documentation has moved to <a href="https://docs.upsun.com/api/">https://docs.upsun.com/api/</a></p></body></html>' >> "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/index.html"
27+
# Public API Docs
28+
mkdir -p "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/styles"
29+
if [ -f "${PLATFORM_APP_DIR}/shared/pages/api.html" ]; then
30+
# @todo refactor so we're not copying over the old platform.sh api docs as well or just remove them
31+
cp -a "${PLATFORM_APP_DIR}/shared/pages/." "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/"
32+
mv "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/api.html" "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/index.html"
33+
cp "${PLATFORM_APP_DIR}/shared/pages/api-style.css" "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/styles/style.css"
34+
else
35+
echo "<p>Currently under maintenance. Please check back later.</p>" >> "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/index.html"
36+
fi
37+
38+
# Internal API Docs
39+
mkdir -p "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/styles"
40+
if [ -f "${PLATFORM_APP_DIR}/shared/pages/api-internal.html" ]; then
41+
# @todo refactor so we're not copying over the old platform.sh api docs as well or just remove them
42+
cp -a "${PLATFORM_APP_DIR}/shared/pages/." "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/"
43+
mv "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/api-internal.html" "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/index.html"
44+
cp "${PLATFORM_APP_DIR}/shared/pages/api-style.css" "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/styles/style.css"
45+
else
46+
echo "<p>Currently under maintenance. Please check back later.</p>" >> "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/index.html"
47+
fi
3148
3249
cd $SITE_DIR
3350
cp ../../themes/psh-docs/postcss.config.js .
@@ -71,6 +88,11 @@
7188
root: 'sites/platform/public/api'
7289
index: [ 'index.html' ]
7390
expires: 24h
91+
'/api-internal':
92+
root: 'sites/platform/public/api-internal'
93+
index: [ 'index.html' ]
94+
expires: 24h
95+
7496
disk: 1024
7597

7698
mounts:
@@ -107,6 +129,8 @@
107129
build: |
108130
#copy API docs into correct location
109131
# @todo once api docs are fully moved we can alter the template.hbs file so style.css can be in /api
132+
133+
# Public API Docs
110134
mkdir -p "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/styles"
111135
if [ -f "${PLATFORM_APP_DIR}/shared/pages/api.html" ]; then
112136
# @todo refactor so we're not copying over the old platform.sh api docs as well or just remove them
@@ -116,6 +140,18 @@
116140
else
117141
echo "<p>Currently under maintenance. Please check back later.</p>" >> "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api/index.html"
118142
fi
143+
144+
# Internal API Docs
145+
mkdir -p "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/styles"
146+
if [ -f "${PLATFORM_APP_DIR}/shared/pages/api-internal.html" ]; then
147+
# @todo refactor so we're not copying over the old platform.sh api docs as well or just remove them
148+
cp -a "${PLATFORM_APP_DIR}/shared/pages/." "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/"
149+
mv "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/api-internal.html" "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/index.html"
150+
cp "${PLATFORM_APP_DIR}/shared/pages/api-style.css" "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/styles/style.css"
151+
else
152+
echo "<p>Currently under maintenance. Please check back later.</p>" >> "${PLATFORM_APP_DIR}/${SITE_DIR}/public/api-internal/index.html"
153+
fi
154+
119155
cd $SITE_DIR
120156
cp ../../themes/psh-docs/postcss.config.js .
121157
npm install
@@ -161,6 +197,10 @@
161197
root: 'sites/upsun/public/api'
162198
index: [ 'index.html' ]
163199
expires: 24h
200+
'/api-internal':
201+
root: 'sites/upsun/public/api-internal'
202+
index: [ 'index.html' ]
203+
expires: 24h
164204

165205
disk: 1024
166206

0 commit comments

Comments
 (0)