Skip to content

Commit 19033cf

Browse files
committed
update readme and provide a github action
1 parent 363dcaf commit 19033cf

3 files changed

Lines changed: 113 additions & 21 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- created
1111

1212
jobs:
13-
test:
13+
build:
1414
runs-on: ubuntu-latest
1515

1616
steps:
@@ -29,23 +29,7 @@ jobs:
2929

3030
- run: npm run lint
3131

32-
- run: |
33-
set -a
34-
. ./.env.example
35-
set +a
36-
npm run test
37-
38-
- uses: coverallsapp/github-action@master
39-
with:
40-
github-token: ${{ secrets.github_token }}
41-
42-
- name: Login to dockerhub
43-
if: ${{ github.event_name != 'pull_request' }}
44-
uses: docker/login-action@v1
45-
with:
46-
registry: docker.pkg.github.com
47-
username: ${{ github.actor }}
48-
password: ${{ secrets.GITHUB_TOKEN }}
32+
- run: npm run test
4933

5034
- id: docker_meta
5135
uses: crazy-max/ghaction-docker-meta@v1
@@ -59,10 +43,15 @@ jobs:
5943
org.opencontainers.image.vendor=appvia
6044
org.opencontainers.image.documentation=https://github.com/appvia/githubUserManager
6145
org.opencontainers.image.authors=Chris Nesbitt-Smith <chris.nesbitt-smith@appvia.io>
62-
org.opencontainers.image.url=https://github.com/appvia/githubUserManager
6346
maintainer=appvia
6447
65-
48+
- name: Login to docker registry
49+
if: ${{ github.event_name != 'pull_request' }}
50+
uses: docker/login-action@v1
51+
with:
52+
registry: docker.pkg.github.com
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
6655

6756
- name: Push to GitHub Packages
6857
uses: docker/build-push-action@v2

README.md

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
# Manage github organisation membership with Google Workspace user accounts
2+
3+
[![Known Vulnerabilities](https://snyk.io/test/github/appvia/githubUserManager/badge.svg)](https://snyk.io/test/github/appvia/githubUserManager)
4+
[![GitHub license](https://img.shields.io/github/license/appvia/githubUserManager)](https://github.com/appvia/githubUserManager/blob/main/LICENSE)
5+
[![GitHub stars](https://img.shields.io/github/stars/appvia/githubusermanager)](https://github.com/appvia/githubusermanager/stargazers)
6+
[![GitHub forks](https://img.shields.io/github/forks/appvia/githubusermanager)](https://github.com/appvia/githubusermanager/network)
7+
[![GitHub issues](https://img.shields.io/github/issues/appvia/githubusermanager)](https://github.com/appvia/githubusermanager/issues)
8+
[![ci](https://github.com/appvia/githubUserManager/actions/workflows/ci.yml/badge.svg)](https://github.com/appvia/githubUserManager/actions/workflows/ci.yml)
9+
10+
Manages who is in your GitHub organization based on a custom property in their Google Workspace profile, allowing for seamless JML (Joiner mover leaver) process, if allowed removing/disabling an account in the Google Workspace will remove the user from the GitHub; similarly adding a user also works the same way. If you don't want to run it in destructive mode it can be configured to exit with a non-zero exit code so that you know to go and manually make the changes.
11+
12+
Right now this only handles the organization membership, it **does not** touch team membership, or level of membership; the main focus is to draw alert when the configuration isn't as expected, these features could be added in future.
13+
114
## Deployment
215

16+
### Collect the secrets
17+
318
1. [Add a custom attribute on the users](https://support.google.com/a/answer/6208725?hl=en#zippy=%2Cadd-a-new-custom-attribute)
419

520
1. Go to https://admin.google.com/ac/customschema
@@ -62,7 +77,46 @@
6277
1. Click `Install`
6378
- take node of the url, it'll look something like: `github.com/organizations/myorg/settings/installations/15627551`, the installationId is the last number `15627551`
6479

65-
## RUN
80+
### Run
81+
82+
#### Github Action:
83+
84+
```yaml
85+
# ./github/workflows/org-membership.yml
86+
name: Github Org Membership
87+
88+
on:
89+
schedule:
90+
- cron: '*/5 * * * *'
91+
jobs:
92+
run:
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Github Org Membership Manager
96+
uses: appvia/githubUserManager@v1
97+
with:
98+
google-email-address: hello@example.com
99+
google-credentials: ${{ secrets.GOOGLE_CREDENTIALS }}
100+
add-users: 'false'
101+
remove-users: 'false'
102+
exit-code-on-missmatch: '1'
103+
github-org: 'myorg'
104+
github-app-id: 1234
105+
github-installation-id: 12345
106+
github-private-key: ${{ secrets.GITHUB_PRIVATE_KEY }}
107+
ignored-users: user1,user2
108+
```
109+
110+
#### Docker
111+
112+
1. make an [env file](https://www.digitalocean.com/community/tutorials/how-to-read-and-set-environmental-and-shell-variables-on-linux) with the [below table](#Setup-environment-variables)
113+
1. `docker run --env-file .env docker.pkg.github.com/appvia/githubusermanager/githubusermanager:main`
114+
115+
#### node/lambda/cloud run/ something else
116+
117+
1. clone this repo
118+
1. `npm install --production`
119+
1. `npm start` (with the with the [below environment variables table](#Setup-environment-variables) set)
66120

67121
### Setup environment variables
68122

action.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: 'Google workspace user to GitHub Org User'
2+
description: 'Manage GitHub organisation membership with Google Workspace user accounts'
3+
author: Chris Nesbitt-Smith
4+
inputs:
5+
google-email-address:
6+
description: 'Email address to assume to, needs to be an workspace admin'
7+
required: true
8+
google-credentials:
9+
description: 'Base64'd json as downloaded from the google service account creation step'
10+
required: true
11+
add-users:
12+
description: 'Set to TRUE to add users to the github organisation'
13+
required: true
14+
remove-users:
15+
description: 'Set to TRUE to remove users from the github organisation'
16+
required: false
17+
exit-code-on-missmatch:
18+
description: 'Exit code to use when there's a mismatch, useful when combined with `ADD_USERS` and `REMOVE_USERS` to be used in a dry-run mode'
19+
required: false
20+
github-org:
21+
description: 'GitHub Organization '
22+
required: true
23+
github-app-id:
24+
description: 'GitHub App ID'
25+
required: true
26+
github-installation-id:
27+
description: 'Github App Installation ID'
28+
required: true
29+
github-private-key:
30+
description: 'Base64'd private key as downloaded from github application registration step'
31+
required: true
32+
ignored-users:
33+
description: 'Comma separated list of user ids to totally ignore always, useful for owners of an org you don't accidentally removed'
34+
required: false
35+
runs:
36+
using: 'docker'
37+
image: 'Dockerfile'
38+
env:
39+
GOOGLE_EMAIL_ADDRESS: ${{ inputs.google-email-address }}
40+
GOOGLE_CREDENTIALS: ${{ inputs.google-credentials }}
41+
ADD_USERS: ${{ inputs.add-users }}
42+
REMOVE_USERS: ${{ inputs.remove-users }}
43+
EXIT_CODE_ON_MISMATCH: ${{ inputs.exit-code-on-missmatch }}
44+
GITHUB_ORG: ${{ inputs.github-org }}
45+
GITHUB_APP_ID: ${{ inputs.github-app-id }}
46+
GITHUB_INSTALLATION_ID: ${{ inputs.github-installation-id }}
47+
GITHUB_PRIVATE_KEY: ${{ inputs.github-private-key }}
48+
IGNORED_USERS: ${{ inputs.ignored-users }}
49+

0 commit comments

Comments
 (0)