Skip to content

Commit

Permalink
Merge pull request #348 from snyk-tech-services/docs/update-github-mi…
Browse files Browse the repository at this point in the history
…rror-token-docs

docs: clarify which API token to use for Github vs GHE
  • Loading branch information
lili2311 authored Aug 1, 2022
2 parents a101f34 + bd81779 commit ca4d931
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/mirror-github.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Mirroring Github.com / Github Enterprise organizations and repos in Snyk

You will need your Snyk API token, with correct scope & [admin access for all Organizations](https://snyk.docs.apiary.io/#reference/import-projects/import/import-targets) you are importing to. As Github is both an auth & integration, how the integration is done has an effect on usage:
- For users importing via [Github Snyk integration](https://docs.snyk.io/integrations/git-repository-scm-integrations/github-integration#setting-up-a-github-integration) use your **personal Snyk API token** (Service Accounts are not supported for Github integration imports via API as this is a personal auth token only accessible to the user)
- For Github Enterprise Snyk integration with a url & token (for Github.com, Github Enterprise Cloud & Github Enterprise hosted) use a **Snyk API service account token**

In order to import the entirety of Github/Github Enterprise repos into Snyk you can use the available utils to make it possible in 4 commands.
You will need to configure both Github token and Snyk token as environment variable to proceed.
Please refer to individual documentation pages for more detailed info, however the general steps are:
Expand All @@ -9,7 +14,7 @@ Please refer to individual documentation pages for more detailed info, however t
4. Generate import data `snyk-api-import import:data --orgsData=snyk-created-orgs.json --source=github --integrationType=github` [Full instructions](./import-data.md)
5. Run import `DEBUG=*snyk* snyk-api-import import`[Full instructions](./import.md)

## Re-importing new repos & orgs only while Mirroring
## Re-importing new repos & organizations only while mirroring
Once initial import is complete you may want to periodically check for new repos and make sure they are added into Snyk. To do this a similar flow to what is described above with a few small changes can be used:
1. `export GITHUB_TOKEN=***` and `export SNYK_TOKEN=***`
2. Generate organization data in Snyk and skip any that do not have any repos via `--skipEmptyOrg` `snyk-api-import orgs:data --source=github --groupId=<snyk_group_id> --skipEmptyOrg` [Full instructions](./orgs.md)
Expand Down

0 comments on commit ca4d931

Please sign in to comment.