Skip to main content

django-sync-github-teams

django-sync-github-teams adds the ability to sync between Github teams and groups in a Django application. It assumes and requires having users logging in to the Django application using their GitHub accounts via django-allauth. Check the django-allauth documentation for details on how to set it up.

Installing and configuring

Install the package

pip install django-sync-github-teams

The in Django settings:

INSTALLED_APPS = [
   ...
   "django_sync_github_teams",
   "allauth",
   "allauth.account",
   "allauth.socialaccount",
   ...
]

AUTH_SOCIALACCOUNT = {
    ...
    "github": {
        "SCOPE": ["user"]
    },
    ...
}

SYNC_GITHUB_TEAMS = ["myorg/myteam"]
SYNC_GITHUB_TEAMS_TOKEN = "*********************"
SYNC_GITHUB_TEAMS_ON_LOGIN = False

The follwing settings can be used:

  • SYNC_GITHUB_TEAMS: list of strings containing the GitHub teams in the format ORGANIZATION/TEAM to be synced from GitHub. Each team listed will be synced to a local Django group with same name. Only users who have logged in locally using their GitHub accounts get added to the group.
    • SYNC_GITHUB_TEAMS can also be a string with teams in the format ORGANIZATION/TEAM separated by commas with optional surounding whitespace, e.g. SYNC_GITHUB_TEAMS = "myorg/team1, myorg/team2", or just by whitespace, e.g. SYNC_GITHUB_TEAMS = "myorg/team1 myorg/team2".
  • SYNC_GITHUB_TEAMS_TOKEN: string containing a GitHub API Personal access token to be used to read the team members. This token must have permissions to read the members of all of the teams listed in SYNC_GITHUB_TEAMS. See the GitHub API documentation for more details about this.
  • SYNC_GITHUB_TEAMS_ON_LOGIN: boolean; if set to True, a user's group will be populated when they login.

Usage

There's a management command to trigger the sync, which can be used in cronjobs and the like:

./manage.py sync-github-teams

You can also trigger this in some other way from your application somehow:

from django_sync_github_teams.sync import sync_github_teams

sync_github_teams()

This needs to run as often as your application requires. Note that even if you enable syncing teams on login, you still need to sync them offline like this from time to time, because users might leave the teams there where members of when they first logged in.

Contributing

Send merge requests at https://gitlab.com/Linaro/django-sync-github-teams. Follow the existing coding conventions in the code (PEP-8, black), and make sure the all the tests pass and that any new code is covered by tests. Just running make will run all relevant tests.

Metadata

Release files for django-sync-github-teams 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sync-github-teams 0.2.0
File Size Uploaded
django-sync-github-teams-0.2.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-sync-github-teams 0.2.0
File Interpreter ABI Platform
django_sync_github_teams-0.2.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 13.8 kB

Release files / django-sync-github-teams-0.2.0.tar.gz

Download URL django-sync-github-teams-0.2.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
95cd44837095685168e1c9993014624e2c68371d0828d110964d17f170f61d81
BLAKE2b-256 checksum
How to use checksums
674a18938159187e3784b811edd283b755d124e69c057b1a67bf816cd357dda7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release files / django_sync_github_teams-0.2.0-py2.py3-none-any.whl

Download URL django_sync_github_teams-0.2.0-py2.py3-none-any.whl
Size 5.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a7809e56a410de34927503e1235fead4022096279afc03ee95eac37711df39a2
BLAKE2b-256 checksum
How to use checksums
4e065b5fadbddacecc5debfe23e0f10404f4cf4f72f7cbaaacc527bb8f2ef924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.28.1

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page