Skip to content

Commit

Permalink
Replace GitHub Pages with mil.ufl.edu (#1170)
Browse files Browse the repository at this point in the history
* Setup SFTP to replace GitHub pages for non-master branches

* Add replacement docs builder

* Update docs template to show last-updated at date

* Update CI to use port 266, fix building docs on master

* Add recursive star for sftp

* trying quotes

* Use relative dir

* Testing lftp for easier control over moving big directories with sftp

* Supplying github workspace into local folder name for lftp command

* Trying with sshpass and sftp commands

* Fixing sshpass escape slash

* Disable StrictHostKeyChecking in sftp

* Finish up sftp/lftp docs

* Remove uses clause
  • Loading branch information
cbrxyz authored Mar 30, 2024
1 parent fd45a13 commit 342d08a
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 43 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,16 @@ jobs:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y rsync
# Publish the artifact to the GitHub Pages branch
- name: Push docs to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.INVESTIGATOR_BOT_TOKEN }}
branch: main
repository-name: uf-mil/uf-mil.github.io
folder: ${{ github.workspace }}/build/docs
target-folder: docs
commit-message: Updating docs to ${{ github.sha }}
- name: Push docs to mil.ufl.edu
run: |
# Install sshpass
sudo apt-get install sshpass
# Upload contents of local folder to remote folder
sshpass -p ${{ secrets.MIL_UFL_SFTP_PASS }} \
sftp -o StrictHostKeyChecking=no \
-P ${{ secrets.MIL_UFL_SFTP_PORT }} [email protected] << EOF
cd htdocs/docs
lcd ${{ github.workspace }}/build/docs
put -r .
exit
EOF
64 changes: 31 additions & 33 deletions .github/workflows/gh_pages.yaml → .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ concurrency:

jobs:
deploy:
runs-on: ubuntu-20.04
runs-on: self-hosted
steps:
- name: Wait to let checks appear
run: sleep 1m
Expand Down Expand Up @@ -47,31 +47,32 @@ jobs:
commit: ${{ github.event.pull_request.head.sha }}
path: ${{ github.workspace }}/pr-docs

# We need to install rsync for GitHub Pages deploy action
- name: Install rsync
run: |
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y rsync
- name: Move folders
if: github.event.action != 'closed'
run: |
cd ${{ github.workspace }}/pr-docs
mv docs-ci-html-${{ github.event.pull_request.head.sha }} ${{ github.event.number }}
echo "datetime=$(TZ=America/New_York date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV
############################
# If commit was an update/refresh (not close)
############################
# Publish the artifact to the GitHub Pages branch
- name: Push preview to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
- name: Upload docs to mil.ufl.edu
if: github.event.action != 'closed'
with:
token: ${{ secrets.INVESTIGATOR_BOT_TOKEN }}
branch: main
git-config-name: uf-mil-bot
git-config-email: [email protected]
repository-name: uf-mil/uf-mil.github.io
folder: ${{ github.workspace }}/pr-docs/${{ github.event.number }}
target-folder: pr-docs/${{ github.event.number }}
commit-message: "Adding PR preview for PR ${{ github.event.number }}"
run: |
# Install sshpass
sudo apt-get install sshpass
# Upload contents of local folder to remote folder
sshpass -p ${{ secrets.MIL_UFL_SFTP_PASS }} \
sftp -o StrictHostKeyChecking=no \
-P ${{ secrets.MIL_UFL_SFTP_PORT }} [email protected] << EOF
mkdir htdocs/pr-docs/${{ github.event.number }}
cd htdocs/pr-docs/${{ github.event.number }}
lcd ${{ github.workspace }}/pr-docs/${{ github.event.number }}
put -r .
exit
EOF
# Create/update stickied comment
- name: Update stickied comment
Expand All @@ -86,7 +87,7 @@ jobs:
The **docs preview** for this PR is available at
https://uf-mil.github.io/pr-docs/${{ github.event.number }}.
https://mil.ufl.edu/pr-docs/${{ github.event.number }}.
```css
Expand All @@ -102,24 +103,21 @@ jobs:
Have a great day! Go gators! 🐊
############################
# If commit was closed
############################
# If the PR is closed, remove the files
- name: Prepare empty folder
- name: Delete pr-docs folder on mil.ufl.edu
if: github.event.action == 'closed'
run: |
echo "emptydir=$(mktemp -d)" >> $GITHUB_ENV
- name: Prepare deletion folders
uses: JamesIves/github-pages-deploy-action@v4
if: github.event.action == 'closed'
with:
token: ${{ secrets.INVESTIGATOR_BOT_TOKEN }}
branch: main
git-config-name: uf-mil-bot
git-config-email: [email protected]
repository-name: uf-mil/uf-mil.github.io
folder: ${{ env.emptydir }}
target-folder: pr-docs/${{ github.event.number }}
commit-message: Removing PR preview for PR ${{ github.event.number }}
# Install lftp
sudo apt-get install lftp
# Upload docs
lftp -u mil,${{ secrets.MIL_UFL_SFTP_PASS }} \
-p ${{ secrets.MIL_UFL_SFTP_PORT }} sftp://mil.ufl.edu << EOF
rm -r htdocs/pr-docs/${{ github.event.number }}
exit
EOF
# Create/update stickied comment
- name: Update stickied comment
Expand Down
3 changes: 3 additions & 0 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<div id="sidebar">
{%- include "searchbox.html" %}
{%- include "globaltoc.html" %}
{% if last_updated %}
<p><i>Last updated on: {{ last_updated }}.</i></p>
{% endif %}
</div>
</aside>
<main class="grid-item" role="main">
Expand Down
6 changes: 5 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import datetime
import os
import os.path
import sys
Expand Down Expand Up @@ -88,6 +89,9 @@

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
now = datetime.datetime.now().astimezone()
# Sun, Jan 30th, 2024 11:59 PM (EST)
html_last_updated_fmt = now.strftime("%a, %b %d, %Y %I:%M %p (%Z)")

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
Expand All @@ -102,7 +106,7 @@

# General information about the project.
project = "mil"
copyright = "2019-2022, Machine Intelligence Lab"
copyright = "2019-2024, Machine Intelligence Lab"
author = "Machine Intelligence Lab"

# The version info for the project you're documenting, acts as replacement for
Expand Down

0 comments on commit 342d08a

Please sign in to comment.