|
| 1 | +# GitHub Workflows |
| 2 | + |
| 3 | +Use GitHub when you want Hack to do GitHub work for you. |
| 4 | + |
| 5 | +GitHub is not part of the base Hack setup. You do not need it for `hack init`, `hack up`, |
| 6 | +`hack open`, logs, local sessions, tickets, or public-repo remote workflows. |
| 7 | + |
| 8 | +GitHub currently unlocks three things: |
| 9 | + |
| 10 | +1. PR automation from Hack. |
| 11 | +2. Private GitHub repo bootstrap on remote nodes when the node cannot already clone the repo. |
| 12 | +3. A named GitHub profile that Hack Desktop and the CLI can route explicitly. |
| 13 | + |
| 14 | +This is also separate from signing in to Hack with GitHub. `Sign in to Hack` controls your Hack |
| 15 | +account. `Connect GitHub integration` gives Hack a GitHub identity it can use for GitHub-specific |
| 16 | +workflows. |
| 17 | + |
| 18 | +## When GitHub Is Optional |
| 19 | + |
| 20 | +Leave GitHub disconnected if you are only using Hack for: |
| 21 | + |
| 22 | +- local orchestration |
| 23 | +- project routing and HTTPS |
| 24 | +- logs and diagnostics |
| 25 | +- tickets or Linear workflows |
| 26 | +- remote execution against public repos |
| 27 | +- remote execution where the node already has working Git credentials |
| 28 | + |
| 29 | +## When GitHub Is Required |
| 30 | + |
| 31 | +Connect GitHub when you want either of these workflows: |
| 32 | + |
| 33 | +- `hack dispatch run --pr` or `hack x github pr-upsert` |
| 34 | +- controller-assisted clone fallback for a private GitHub repo on a remote node |
| 35 | + |
| 36 | +If the remote node can already clone the repo on its own, GitHub stays optional even for remote |
| 37 | +execution. |
| 38 | + |
| 39 | +## Fastest Setup By Goal |
| 40 | + |
| 41 | +### 1. Interactive setup for a person using Hack |
| 42 | + |
| 43 | +Use browser auth and pick an installation: |
| 44 | + |
| 45 | +```bash |
| 46 | +hack x github oauth-connect --profile personal --set-default |
| 47 | +``` |
| 48 | + |
| 49 | +Use this when you want the simplest path to PR automation or private-repo fallback. |
| 50 | + |
| 51 | +### 2. Bring an existing token |
| 52 | + |
| 53 | +Use this when you already manage a token outside Hack: |
| 54 | + |
| 55 | +```bash |
| 56 | +hack x github connect --profile default --token-env HACK_GITHUB_APP_TOKEN |
| 57 | + |
| 58 | +# or: |
| 59 | +printf "%s" "$HACK_GITHUB_APP_TOKEN" | hack x github connect --profile default --stdin |
| 60 | +``` |
| 61 | + |
| 62 | +### 3. Use GitHub App credentials for least privilege |
| 63 | + |
| 64 | +Use this when you want installation-scoped auth that can refresh automatically: |
| 65 | + |
| 66 | +```bash |
| 67 | +hack x github connect \ |
| 68 | + --profile work \ |
| 69 | + --set-default \ |
| 70 | + --app-id 12345 \ |
| 71 | + --installation-id 67890 \ |
| 72 | + --private-key-env HACK_GITHUB_APP_PRIVATE_KEY |
| 73 | +``` |
| 74 | + |
| 75 | +## Common Commands |
| 76 | + |
| 77 | +```bash |
| 78 | +hack x github profiles |
| 79 | +hack x github use --profile work |
| 80 | +hack x github status --profile work |
| 81 | +hack x github disconnect --profile work |
| 82 | +``` |
| 83 | + |
| 84 | +PR creation/update: |
| 85 | + |
| 86 | +```bash |
| 87 | +hack x github pr-upsert \ |
| 88 | + --profile work \ |
| 89 | + --repo owner/repo \ |
| 90 | + --head my-branch \ |
| 91 | + --base main \ |
| 92 | + --title "My PR" \ |
| 93 | + --body "Details" |
| 94 | +``` |
| 95 | + |
| 96 | +## Profile Selection |
| 97 | + |
| 98 | +Hack resolves the GitHub profile in this order: |
| 99 | + |
| 100 | +1. `--profile` |
| 101 | +2. `controlPlane.routing.overrides.github.profile` |
| 102 | +3. `controlPlane.extensions["dance.hack.github"].config.defaultProfile` |
| 103 | + |
| 104 | +Use separate profiles when you need different GitHub identities for different repos or automations. |
| 105 | + |
| 106 | +## Browser Auth Requirements |
| 107 | + |
| 108 | +`hack x github oauth-connect` needs the GitHub OAuth app config in global Hack config: |
| 109 | + |
| 110 | +- `controlPlane.extensions["dance.hack.github"].config.oauthClientId` |
| 111 | +- `controlPlane.extensions["dance.hack.github"].config.oauthClientSecretAuthRef` |
| 112 | + |
| 113 | +The referenced secret is stored in the OS keychain under service `hack-github-auth`. |
0 commit comments