Skip to content

Commit 86d153b

Browse files
authored
W2 updates
Updated prerequisites and instructions for cloud box setup. Clarified token usage and added notes on credential management.
1 parent 56aec41 commit 86d153b

1 file changed

Lines changed: 41 additions & 43 deletions

File tree

progression/W2-cloud-box-and-preflight.md

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,20 @@ By the end of this session `./preflight.sh` prints `PREFLIGHT: PASS` wherever yo
2424

2525
## Prereqs
2626

27-
- macOS or Linux, on amd64 or arm64.
28-
- A GitHub account, and a repository you can push to for the rig.
29-
- Roughly fifteen minutes, most of it waiting on downloads.
27+
- MacOS or Linux (or Windows with [WSL](https://learn.microsoft.com/en-us/windows/wsl/install)) installed
28+
- A GitHub account with the ability to create new repositories.
3029

3130
## Context
3231

33-
Nothing in the rest of the curriculum works until preflight passes, and the failures it catches are all cheaper to find now than at step nine of the next session.
32+
Nothing in the rest of the curriculum works until the preflight check passes, and the failures it catches are all cheaper to find now than at step nine of the next session.
3433

35-
Most participants work on an instructor-provided cloud box, which is the path below. Your own machine works too, and that path is in the appendix at the end of this page. Do one of them, not both.
34+
Most participants should work on an instructor-provided cloud box, which is the path below. Your own machine works too, and that path is in the appendix at the end of this page. Do one of them, not both.
3635

3736
## The cloud box (recommended)
3837

38+
Getting onto the box is its own page. [`CLOUD_BOX_GUIDE.md`](../CLOUD_BOX_GUIDE.md) takes the four values your instructor sends you through to a running factory. Work through it first, then come back here for the preflight run below.
3939

40-
Getting onto the box is its own page. [`CLOUD_BOX_GUIDE.md`](../CLOUD_BOX_GUIDE.md) takes the four values your instructor sends you through to a running factory, and it is the one place those steps live. Work through it first, then come back here for the preflight run below.
41-
42-
### Signing the box in with a token
40+
### Signing into the box with a token
4341

4442
The box holds its own GitHub credential, separate from the one on your laptop, and [step 5 of the box guide](../CLOUD_BOX_GUIDE.md#step-5-the-first-run-login) is where it gets one. That step asks which way you would like to give it:
4543

@@ -58,33 +56,25 @@ The box holds its own GitHub credential, separate from the one on your laptop, a
5856
Which route? [1]
5957
```
6058

61-
A bare Enter takes the browser grant, which is what the rest of the guide assumes and what most of the room will take. Answering `2` prompts for a token instead. It is read without echoing, checked against GitHub before anything is written, and stored readable only by the factory user. Both routes then check that the account can actually read the repositories the box provisions from, so a credential that authenticates but cannot reach them fails at the prompt rather than three minutes later inside a clone.
62-
63-
So the choice about a broad grant is yours on a box, the same as it is on your laptop above. The only thing to arrange beforehand is the token itself. Mint it before you start step 5 and have it ready when the prompt appears.
64-
65-
You will only meet that menu on a box that holds no credential yet. If step 5 tells you it is already authenticated as somebody, then someone has been here before you, and it names the `gh auth logout` that hands the choice back.
66-
67-
If the paste comes back empty or GitHub rejects it, nothing is written and first-run stops there rather than carrying on without a credential. Resume with `sudo gas-city-login --from github`, which redoes the sign-in and continues through the steps that had not run yet. Reaching for `gas-city-set-token` on its own instead is the tempting mistake: it writes the token and leaves the box unprovisioned.
68-
69-
`gas-city-set-token` is what replaces the box's credential later, and the order there is not obvious. It refuses to run while the box still holds a `gh` credential, because that credential wins over the token file and the token would be written and then ignored. So drop that one first:
70-
71-
**Copy and paste**
72-
73-
```bash
74-
ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" gh auth logout --hostname github.com
75-
ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" sudo gas-city-set-token
76-
ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" sudo gas-city-refresh
77-
```
78-
79-
The first line is only needed if the box took the browser route at step 5; a box already on a pasted token has no `gh` credential to drop. The last line is the part that is easy to leave off, and the swap is not finished without it: the agents already running keep the old credential until the service restarts. `gas-city-refresh` rewrites the factory's environment from the stored token, restarts the service, and prints its status so you can see it came back.
59+
A bare `Enter` takes the browser grant, which is what the rest of the guide assumes and what most of the room will take. Answering `2` prompts for a token instead. It is read without echoing, checked against GitHub before anything is written, and stored readable only by the factory user. Both routes then check that the account can actually read the repositories the box provisions from, so a credential that authenticates but cannot reach them fails at the prompt. If you would like to use a restricted grant token, be sure to mint it before you start step 5 and have it ready when the prompt appears.
8060

81-
The way back is open too. `sudo gas-city-login github` on a box holding a pasted token offers the browser route and defaults to keeping the token, so a box is never stuck on whichever credential it was given first.
61+
If GitHub rejects it or you run into issues with the GitHub credential, nothing is written and first-run stops there rather than carrying on without a credential. Resume with `sudo gas-city-login --from github`, which redoes the sign-in and continues through the steps that had not run yet.
8262

83-
This route needs no `gh auth setup-git`, unlike the laptop ones. The box wires `git` to a credential helper that asks for whichever credential the box currently holds, so it keeps working across a swap in either direction.
63+
> [!NOTE]
64+
> If you would like to change the credential later, run the following (or else it will refuse to drop the existing `gh` credential):
65+
> ```bash
66+
> ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" gh auth logout --hostname github.com
67+
> ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" sudo gas-city-set-token
68+
> ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" sudo gas-city-refresh
69+
> ```
70+
> Alternatively, the following command on a box holding a pasted token offers the browser route and defaults to keeping the token:
71+
> ```bash
72+
> ssh -t -F ~/.gascity/ssh_config "$SFI_BOX" sudo gas-city-login github
73+
> ```
8474
85-
On scopes, the two routes ask for the same thing. The browser grant yields `repo`, `read:org`, `gist` and `workflow`. The token prompt asks for a classic token with `repo`, plus `workflow` if any repository the agents touch carries GitHub Actions workflows, or a fine-grained one with contents and pull-requests read and write, plus workflows, on those repositories. Scope it for the whole two days rather than for the clone. A read-only token is enough to provision the box and then stops at the first push, which is a failure that arrives once the agents are already working.
75+
On scopes, the two routes ask for the same thing. The browser grant yields `repo`, `read:org`, `gist` and `workflow`. The token prompt asks for a classic token with `repo`, plus `workflow` if any repository the agents touch carries GitHub Actions workflows, or a fine-grained one with contents and pull-requests read and write, plus workflows, on those repositories.
8676
87-
### Run preflight against the box
77+
### Run preflight against the cloud box
8878
8979
**Copy and paste**
9080
@@ -106,12 +96,9 @@ Cloud path
10696
PREFLIGHT: PASS
10797
```
10898
109-
The reachability check delegates to `sfbox preflight`, which walks the three layers in order and stops at the first one that fails. That ordering is the useful part: it tells you whether the problem is SSH, a missing `gc`, or the Gas City service, so you know which of the three to fix instead of guessing.
110-
11199
## Appendix: running it on your own machine
112100
113-
Everything below works, and it is the fallback rather than the taught path. If you are on an instructor-provided box, you are already done; skip to [What's next](#whats-next).
114-
101+
Everything below is the fallback if you would like to run the curriculum on your local machine. If you are on an instructor-provided cloud box, skip to [What's next](#whats-next).
115102
116103
### 1. Clone the tutorial
117104
@@ -148,7 +135,25 @@ Do what that last line says if you have not already:
148135
export PATH="$HOME/.local/bin:$PATH"
149136
```
150137
151-
Add it to `~/.zshrc` or `~/.bashrc` too so new session windows also contain it.
138+
Then, add the variables to `~/.zshrc` or `~/.bashrc` too so new session windows contain it:
139+
140+
**Copy and paste** (macOS / zsh)
141+
142+
```bash
143+
cat <<EOF >> ~/.zshrc
144+
export SOFTWARE_FACTORY_INTENSIVE_PATH="$SOFTWARE_FACTORY_INTENSIVE_PATH"
145+
export PATH="$HOME/.local/bin:$PATH"
146+
EOF
147+
```
148+
149+
**Copy and paste** (Linux / bash)
150+
151+
```bash
152+
cat <<EOF >> ~/.bashrc
153+
export SOFTWARE_FACTORY_INTENSIVE_PATH="$SOFTWARE_FACTORY_INTENSIVE_PATH"
154+
export PATH="$HOME/.local/bin:$PATH"
155+
EOF
156+
```
152157
153158
### 3. Run preflight
154159
@@ -157,7 +162,6 @@ Add it to `~/.zshrc` or `~/.bashrc` too so new session windows also contain it.
157162
```bash
158163
./preflight.sh
159164
```
160-
161165
**Expected output**
162166
163167
```text
@@ -199,12 +203,6 @@ If you would rather not grant that, paste a personal access token instead. Both
199203
gh auth login --with-token < your-token-file
200204
```
201205
202-
**Fine-grained token.** This is the kind that scopes to individual repositories, so it is the one to reach for if the whole point is keeping the rest of your account out of reach. Do not pass it to `--with-token`: `gh` warns that the resource scoping causes confusing behaviour on commands that touch anything outside the token's repositories. Set the environment variable instead, and add it to your shell rc so a new terminal keeps it:
203-
204-
```bash
205-
export GH_TOKEN=<your-token>
206-
```
207-
208206
Grant it **Contents**, **Pull requests**, and **Administration**, all write, on the repository you will push the rig to. Administration is the one that is easy to miss — [the branch-protection appendix](../appendix/03-branch-protection.md) needs it to install branch protection, and that failure lands an hour into day one. A fine-grained token also has to name a repository that already exists, and the rig's repository is created on [W3 Run Your Factory](./W3-run-your-factory.md), so either create it now or come back and re-scope the token then.
209207
210208
**Either token needs one more command.** `--with-token` and `GH_TOKEN` both authenticate `gh` without telling `git` anything, so `git push` still fails with `could not read Username for 'https://github.com'`. The browser flow wires this up for you and the token routes do not:

0 commit comments

Comments
 (0)