Skip to content

Update deploy.yml

Update deploy.yml #10

Workflow file for this run

name: deploy-book
# Only run this when the master branch changes
on:
workflow_dispatch:
push:
branches:
- main
# This job installs dependencies, build the book, and pushes it to `gh-pages`
jobs:
deploy-book:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install dependencies
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: cache installation
uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}
- name: Install dependencies
run: |
pip install -r requirements.txt
# Build the book
- name: Build the book
run: |
jupyter-book build .
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# Push to server
- name: rsync and ssh
env:
REMOTE_HOST: ${{ secrets.FIRAS_REMOTE_HOST }}
REMOTE_USER: ${{ secrets.FIRAS_REMOTE_USER }}
REMOTE_KEY: ${{ secrets.FIRAS_SERVER_SSH_KEY }}
REMOTE_DIR: ${{ secrets.FIRAS_REMOTE_TARGET }}
LOCAL_DIR: "_build/html/"
COURSE_NAME: "cpsc430"
TERM: "2024_S1"
run: |
mkdir ~/.ssh
echo "$REMOTE_KEY" > ~/.ssh/id_rsa
ssh-keyscan -H $REMOTE_HOST >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_rsa
rsync -avzr --delete $LOCAL_DIR $REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR/$COURSE_NAME/$TERM
# Push to CS server
- name: rsync and ssh to CS
env:
COURSE_REMOTE_HOST: "kunghit.students.cs.ubc.ca"
COURSE_REMOTE_USER: "cs-430"
CS_REMOTE_USER: "firasm"
CS_TUNNEL: "remote.cs.ubc.ca"
REMOTE_KEY: ${{ secrets.FIRAS_SERVER_SSH_KEY }}
TERM: "2024_S1"
LOCAL_DIR: "_build/html/"
run: |
mkdir -p ~/.ssh
echo "$REMOTE_KEY" > ~/.ssh/id_rsa
ssh-keyscan -H $REMOTE_HOST >> ~/.ssh/known_hosts
chmod 600 ~/.ssh/id_rsa
# send files all in one shot
rsync -navz -e 'ssh -J $CS_REMOTE_USER@$CS_TUNNEL' $LOCAL_DIR $COURSE_REMOTE_USER@COURSE_REMOTE_HOST:public_html/$TERM