Skip to content

Commit

Permalink
Remove code duplication on code to update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewQuijano committed Dec 6, 2024
1 parent 1dc2915 commit 51afce9
Showing 1 changed file with 23 additions and 43 deletions.
66 changes: 23 additions & 43 deletions .github/workflows/publish_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,32 +151,6 @@ jobs:
target: panda
cache-from: type=registry,ref=pandare/pandadev:cache
cache-to: type=registry,ref=pandare/panda:cache,mode=max

- name: Checkout docs and reset
run: rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
git clone https://panda-jenkins-ci:${{ secrets.PANDABOT_GITHUB_API }}@github.com/panda-re/panda-re.github.io.git --branch=master ${GITHUB_WORKSPACE}/auto_pydoc/pandare

- name: Update PYPANDA docs in container
run: docker run --rm -v ${GITHUB_WORKSPACE}/auto_pydoc:/out pandare/pandadev:latest /bin/sh -c "pip3 install pdoc3==0.10.0; cd /panda/panda/python/core; pdoc3 --html --template-dir=../docs/template --force -o /out/${GITHUB_REF##*/} pandare; chmod -R 777 /out/"

# will put docs in workspace/auto_pydoc/dev/pandare and/or workspace/auto_pydoc/stable/pandare
# we want to copy auto_pydoc/dev/pandare to auto_pydoc/pandare/ and /auto_pydoc/stable/pandare to /auto_pydoc/pandare/stable
#
# This is a bit complicated, sorry. We want to keep pandare/{CNAME,.git/} and nothing else
# then we copy in the new files (and merge doc-search.html and index.js with dev/pandare/
- name: Push PYPANDA docs to GitHub Pages if docs changed
run: cd "${GITHUB_WORKSPACE}/auto_pydoc" &&
mv pandare/CNAME dev &&
rm -rf pandare/* &&
mv dev/pandare/* pandare &&
rmdir dev/pandare &&
mv dev/* pandare/ &&
cd pandare &&
git config --global user.email "panda-ci@panda-re.mit.edu" &&
git config --global user.name "PANDA Bot" &&
git add . &&
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch dev" &&
git push || true

build_stable:
if: github.repository == 'panda-re/panda' && github.ref == 'refs/heads/stable'
Expand All @@ -201,28 +175,34 @@ jobs:
pandare/panda_stable:${{ github.sha }}
pandare/panda_stable:latest
target: panda


update_documentation:
runs-on: panda-arc
needs: [build_stable, upload_release_assets]
if: ${{ github.repository == 'panda-re/panda' && (needs.build_stable.result == 'success' || needs.upload_release_assets.result == 'success') }}
steps:
- name: Checkout docs and reset
run: rm -rf "${GITHUB_WORKSPACE}/auto_pydoc";
git clone https://panda-jenkins-ci:${{ secrets.PANDABOT_GITHUB_API }}@github.com/panda-re/panda-re.github.io.git --branch=master ${GITHUB_WORKSPACE}/auto_pydoc/pandare

- name: Update PYPANDA docs in container
run: docker run --rm -v ${GITHUB_WORKSPACE}/auto_pydoc/pandare:/out pandare/pandadev:latest /bin/sh -c "pip3 install pdoc3==0.10.0; cd /panda/panda/python/core; pdoc3 --html --template-dir=../docs/template --force -o /out/${GITHUB_REF##*/} pandare; chmod -R 777 /out/"

# will put docs in workspace/auto_pydoc/dev/pandare and/or workspace/auto_pydoc/stable/pandare
# we want to copy /auto_pydoc/dev/pandare to /auto_doc and /auto_pydoc/stable/pandare to /auto_pydoc/stable
#
# This is a bit complicated, sorry. We create a directory stable and combine doc-search.html and index.js in there.

# will put docs in workspace/auto_pydoc/{dev, stable}/pandare and/or workspace/auto_pydoc/stable/pandare
# we want to copy auto_pydoc/{dev, stable}/pandare to auto_pydoc/pandare/ and /auto_pydoc/stable/pandare to /auto_pydoc/pandare/stable
#
# This is a bit complicated, sorry. We want to keep pandare/{CNAME,.git/} and nothing else
# then we copy in the new files (and merge doc-search.html and index.js with {dev, stable}/pandare/
- name: Push PYPANDA docs to GitHub Pages if docs changed
#run: cd "${GITHUB_WORKSPACE}/auto_pydoc/pandare" && mv ./stable ./stable2; mv ./stable2/pandare stable; rm -rf ./stable2;
run: cd "${GITHUB_WORKSPACE}/auto_pydoc" &&
rm -rf pandare/stable &&
mv stable/pandare/* pandare/stable &&
rmdir stable/pandare &&
mv stable/* pandare/stable &&
cd pandare &&
git config --global user.email "panda-ci@panda-re.mit.edu" &&
git config --global user.name "PANDA Bot" &&
git add . &&
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch stable" &&
git push || true
mv pandare/CNAME ${{ github.ref_name }} &&
rm -rf pandare/* &&
mv ${{ github.ref_name }}/pandare/* pandare &&
rmdir ${{ github.ref_name }}/pandare &&
mv ${{ github.ref_name }}/* pandare/ &&
cd pandare &&
git config --global user.email "panda-ci@panda-re.mit.edu" &&
git config --global user.name "PANDA Bot" &&
git add . &&
git commit -m "Documentation update for PANDA commit ${{ github.sha }} branch ${{ github.ref_name }}" &&
git push || true

0 comments on commit 51afce9

Please sign in to comment.