Skip to content

Commit

Permalink
fetch docs outside of docker
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Oct 19, 2023
1 parent 2179388 commit 68e8670
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 28 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ jobs:
- name: Fetch documentation
working-directory: ./pwa
run: bash tools/get-docs.sh
- name: Compute source documentation
working-directory: ./pwa
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: phive
run: bash tools/get-core-docs.sh
- name: Build and push
uses: docker/build-push-action@v4
with:
Expand Down
12 changes: 1 addition & 11 deletions pwa/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,11 @@ FROM php as php_documentation_generator

RUN apt-get update && apt-get install -y gnupg git libzip-dev zip
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=phario/phive:0.15.2 /usr/local/bin/phive /usr/bin/phive
RUN docker-php-ext-install zip
RUN phive install --trust-gpg-keys 62D05354C61458CB8378FD323F82299C64F51AD2 --copy php-documentation-generator/php-documentation-generator
COPY docs-versions.txt docs-versions.txt
COPY tools/get-core-docs.sh ./get-core-docs.sh
COPY pdg.config.yaml ./pdg.config.yaml
# this is used to preload data see phpwasm
RUN git clone -b main --single-branch --depth=1 https://github.com/api-platform/core core.docs && \
cd core.docs/docs && \
composer install
RUN bash get-core-docs.sh
# RUN bash get-core-docs.sh

FROM soyuka/php-wasm:8.2.9 as phpwasm
# We want soyuka/php-wasm to compile without js optimisation so that we can `sed`
Expand Down Expand Up @@ -58,8 +52,6 @@ COPY --from=phpwasm --link --chown=nextjs:nodejs /build/php-web.data.js /build/p
COPY --from=phpwasm --link --chown=nextjs:nodejs /build/php-web.mjs /build/php-web.mjs
RUN sed '/--pre-js/r /build/php-web.data.js' /build/php-web.mjs > ./app/playground/utils/php-web.mjs
ADD ./data/docs ./data/docs
COPY --from=php_documentation_generator --chown=nextjs:nodejs ./data/docs/reference ./data/docs/reference
COPY --from=php_documentation_generator --chown=nextjs:nodejs ./data/docs/guides ./data/docs/guides

EXPOSE 3000
ENV PORT 3000
Expand All @@ -78,8 +70,6 @@ COPY --from=phpwasm --link --chown=nextjs:nodejs /build/php-web.data.js /build/p
COPY --from=phpwasm --link --chown=nextjs:nodejs /build/php-web.mjs /build/php-web.mjs
RUN sed '/--pre-js/r /build/php-web.data.js' /build/php-web.mjs > ./app/playground/utils/php-web.mjs
ADD ./data/docs ./data/docs
COPY --from=php_documentation_generator --chown=nextjs:nodejs ./data/docs/reference ./data/docs/reference
COPY --from=php_documentation_generator --chown=nextjs:nodejs ./data/docs/guides ./data/docs/guides

ARG NEXT_ROOT_URL
ENV NEXT_ROOT_URL=$NEXT_ROOT_URL
Expand Down
2 changes: 1 addition & 1 deletion pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"i18n": "ts-node ./update-i18n.ts; prettier ./i18n/dictionaries/*.json --write",
"prebuild": "ts-node ./prebuild.ts",
"postbuild": "ts-node ./postbuild.ts",
"prettier:docs": "prettier --write \"data/docs/**/*.{mdx}\" --parser mdx"
"prettier:docs": "prettier --write \"data/docs/**/*.mdx\" --parser mdx"
},
"dependencies": {
"@docsearch/react": "^3.5.2",
Expand Down
1 change: 1 addition & 0 deletions pwa/tools/get-core-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
root=$(pwd)
IFS=$'\n' read -d '' -r -a versions < docs-versions.txt

phive install --trust-gpg-keys 62D05354C61458CB8378FD323F82299C64F51AD2 --copy php-documentation-generator/php-documentation-generator
rm -rf core.temp
git clone -b main --single-branch --depth=1 https://github.com/api-platform/core core.temp
cd core.temp
Expand Down
16 changes: 0 additions & 16 deletions pwa/tools/get-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,6 @@ do
git worktree add $root/data/docs/$version origin/$version
done

cd $root

rm -rf core.temp
git clone -b main --single-branch --depth=1 https://github.com/api-platform/core core.temp
cd core.temp

mkdir -p $root/data/docs/changelog
for version in "${versions[@]}"
do
git clean -f
git restore .
git fetch --depth=1 origin $version
git checkout FETCH_HEAD -b $version-temp
cp $root/core.temp/CHANGELOG.md $root/data/docs/changelog/$version.mdx
done

find $root/data/docs -depth -name "*.md" -exec sh -c 'mv "$1" "${1%.md}.mdx"' _ {} \;
npm run prettier:docs
find $root/data/docs -name "*.mdx" | xargs sed -i "s/><br>/\/><br \/>/g"
Expand Down

0 comments on commit 68e8670

Please sign in to comment.