From 83ee8d8161daef347277d4ad9ff54ec5ce7527f2 Mon Sep 17 00:00:00 2001 From: Nathaniel Kerr Date: Sat, 30 Nov 2024 22:57:59 -0500 Subject: [PATCH] Add automatic updating --- .github/workflows/update_website.yaml | 21 +++++++++++++++++++++ update.py | 15 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/update_website.yaml create mode 100644 update.py diff --git a/.github/workflows/update_website.yaml b/.github/workflows/update_website.yaml new file mode 100644 index 0000000..084e34e --- /dev/null +++ b/.github/workflows/update_website.yaml @@ -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 }} \ No newline at end of file diff --git a/update.py b/update.py new file mode 100644 index 0000000..7c990d5 --- /dev/null +++ b/update.py @@ -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() \ No newline at end of file