Skip to content

Commit

Permalink
Add automatic updating
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKerr1225 committed Dec 1, 2024
1 parent 86877c4 commit 83ee8d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/update_website.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update website

on:
workflow_dispatch: {}
push:
branches: [ "master" ]

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
run: |
pip3 install websocket-client
- name: Update site
run: |
python3 update.py {{ secrets.ION_CSRF_TOKEN }} {{ secrets.ION_SESSION_ID }}
15 changes: 15 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from websocket import WebSocket
import sys

conn = WebSocket()
conn.connect("wss://director.tjhsst.edu/sites/399/terminal/?", cookie=f"csrftoken={sys.argv[1]};sessionid={sys.argv[2]}")
if 'true' not in conn.recv():
print("Could not connect")
exit(1)

conn.send_bytes(b'./update.sh\n')
conn.recv()
conn.recv()
while '/site#' not in conn.recv().decode():
continue
conn.close()

0 comments on commit 83ee8d8

Please sign in to comment.