Skip to content

Merge pull request #80 from cgtuebingen/feature/renderer-refactor #11

Merge pull request #80 from cgtuebingen/feature/renderer-refactor

Merge pull request #80 from cgtuebingen/feature/renderer-refactor #11

Workflow file for this run

name: Update Website
on:
push:
branches:
- main
workflow_dispatch:
jobs:
update-website:
name: update-website
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PRIVATEKEY }}
known_hosts: unnecessary
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: Update and Restart Server
run: |
ssh ${{ secrets.USER }}@${{ secrets.HOST }} << 'EOF'
set -e
# Install nvm if not installed
if ! command -v nvm &> /dev/null; then
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi
# Load nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# Install and use Node.js v18.20.2
nvm install 18.20.2
nvm use 18.20.2
# Later replace this with secrets.TARGET
cd ${{ secrets.TARGET }}
git pull
yarn install
# Kill existing tmux session if it exists
tmux kill-session -t server || true
# Start a new tmux session with the correct Node.js version
tmux new-session -d -s server 'yarn build && yarn start'
EOF