Calendar synchronisation setup
The MEG lab uses a synchronization workflow to mirror bookings from the Corelabs (Booked) portal to a Google Calendar. This lets researchers use Google Calendar features such as appointment schedules to manage participant bookings while automatically respecting the lab’s availability.
Infrastructure overview
The synchronization has three main components:
Python script: scripts/sync-gcal.py fetches the lab’s ICS feed, parses events, and upserts them into Google Calendar via the Google Calendar API.
Google Cloud project: a service account with Editor access to the specific lab Google Calendar.
GitHub Actions: the workflow .github/workflows/sync-gcal.yml runs every 5 minutes on a self-hosted Windows workstation.
Google Cloud Platform setup
To maintain or update the synchronization, you need access to the Google Cloud project:
Service account: create a service account in the GCP console.
API key: generate a JSON key for the service account and store it securely.
Calendar access: share the target Google Calendar with the service account’s email (found in the JSON key) with Make changes to events permission.
GitHub repository secrets
The following secrets must be configured in the GitHub repository (Settings > Secrets and variables > Actions):
GOOGLE_SA_JSON: the entire content of the service account JSON key file.GOOGLE_CALENDAR_ID: the ID of the target Google Calendar.BOOKED_ICS_URL: the private iCal subscription URL from Corelabs.LOCAL_CONDA_PATH: (optional) path to thecondaexecutable on the self-hosted runner.LOCAL_CONDA_ENV_PATH: (optional) path to the conda environment to use.
Self-hosted runner configuration
The workflow is designed to run on a Windows runner (specifically the MEG workstation) to avoid dependencies on cloud-hosted runners and to leverage local environments.
Windows specific tips:
The workflow uses
pwsh(PowerShell Core) for robust command execution.Environment variables like
CONDA_EXEandCONDA_ENV_PATHare used to invoke the correct Python environment without requiring a fullconda initin every run, which prevents path recursion limits.The service account JSON is created on the runner during each run using the
GOOGLE_SA_JSONsecret and deleted afterward.
Thank you for your contribution.