Skip to content

Companion version visibility on front page

Will Haese-Hill edited this page Mar 27, 2024 · 3 revisions

image

Mechanism for showing latest version number

At companion.ac.uk:/var/www/companion.ac.uk/ there is a script set_version.sh which calls the GitHub API to obtain the latest release version for the sii-companion/companion repository, and stores it in dist/version.txt. The script takes as its first argument a GitHub PAT token which is used to authenticate this API call.

image

A JQuery AJAX call is made in dist/index.html to get the dist/version.txt file and append the contents to the corresponding div. Note that dist/legacy_version.txt is just statically set to v1.0.2 (the last tagged version number from legacy)

image

There is a cron job set to run once per hour which calls set_version.sh .token, where .token is the PAT token stored in the same directory. To edit this cron job (e.g. to change frequency), users with sudo can run the following when SSH'd into the companion.ac.uk server

sudo crontab -u www-data -e

image

If the .token has expired, the placeholder on the front page will just display null. This leads us onto...

Regenerating Personal Access Token

Unfortunately, the PAT generated by GitHub has a maximum expiration time of 1 year and so will need to be regenerated every so often.

  1. Login to github.com
  2. Navigate to Settings > Developer Settings > Personal access tokens > Fine-grained tokens
  3. If this is your first time, follow this guide, where Read-only access to public repositories (default) is fine. Otherwise, select the expired token and click Regenerate token
  4. Make sure to copy the token contents at creation/regeneration time and paste into companion.ac.uk:/var/www/companion.ac.uk/.token

image