|
| 1 | +# Github App for pushing to github from the dev-desktops |
| 2 | + |
| 3 | +These instructions are for server-side setup and debugging of the dev-desktop github app. |
| 4 | +The user only needs to be directed to the app installation URL |
| 5 | +and everything should just work for them. |
| 6 | + |
| 7 | +We're using the python github library for all github operations. |
| 8 | +You can find the docs at https://pygithub.readthedocs.io/en/latest/introduction.html |
| 9 | + |
| 10 | +## How to setup an App |
| 11 | + |
| 12 | +1. Go to https://github.com/settings/apps |
| 13 | +2. New Github App |
| 14 | +3. Fill out metadata (name and url) |
| 15 | +4. disable WebHook checkbox |
| 16 | +5. Set `Contents - Repository contents, commits, branches, downloads, releases, and merges.` to read/write |
| 17 | +6. Set `Workflows - Update GitHub Action workflow files.` to read/write |
| 18 | +7. Set to "enable on any account" |
| 19 | +8. Create App |
| 20 | +9. Go to https://github.com/settings/apps/{your_app_name_here} and copy the `App ID` into `app_id.txt` (same folder as `gen_temp_access_token.py`) |
| 21 | + |
| 22 | +### How to generate a .pem file for your App |
| 23 | + |
| 24 | +1. Go to https://github.com/settings/apps/{your_app_name_here}#private-key and generate a private key |
| 25 | +2. Download starts, save it to somewhere private. |
| 26 | +3. copy the .pem file into the same folder as the `gen_temp_access_token.py` and name it `dev-desktop.private-key.pem` |
| 27 | + |
| 28 | +### How to install the app for a user |
| 29 | + |
| 30 | +1. direct the user to https://github.com/settings/apps/{your_app_name_here}/installations |
| 31 | +2. let them install it on the org/user they want to and restrict to the repositories they want to use |
| 32 | + |
| 33 | +### How to generate a temporary access token for a specific user |
| 34 | + |
| 35 | +1. invoke `gen_temp_access_token.py <github_username> <github_repository_name>` |
| 36 | + |
| 37 | +## Integration into git command line |
| 38 | + |
| 39 | +We're using [credential-helpers](https://git-scm.com/docs/gitcredentials#Documentation/gitcredentials.txt). |
| 40 | +For debugging a credential helper, have it in userspace and invoke it with |
| 41 | + |
| 42 | +`git -c credential.helper -c credential.UseHttpPath=true /path/to/helper push origin branch` |
| 43 | + |
| 44 | +Note that this does not work for remotes that are registered with ssh urls. You must use https! |
| 45 | + |
| 46 | +The first command line argument is `get`, `store` or `remove`. |
| 47 | +In our case, we just abort (`exit(0)`) for everything but `get`, as we regenerate credentials on every invocation anyway. |
| 48 | + |
| 49 | +The actual arguments are passed via stdin and usually look like |
| 50 | + |
| 51 | +``` |
| 52 | +protocol=https |
| 53 | +host=github.com |
| 54 | +path=your_repo.git |
| 55 | +``` |
| 56 | + |
0 commit comments