36 lines
1.8 KiB
Markdown
36 lines
1.8 KiB
Markdown
# Git deployment access
|
|
|
|
A deployment VM can clone this public repository over HTTPS using a dedicated, read-only Git access token when anonymous access is unavailable. The token is used as Git's password; it is never committed, placed in `.env`, included in a clone URL, or printed in receipts.
|
|
|
|
## One-time clone
|
|
|
|
1. In Gitea, create a dedicated token with repository read access only. Use a clear name such as `email-campaigns-prod-app-readonly`.
|
|
2. Connect interactively to the VM as `deploy-user`.
|
|
3. Run:
|
|
|
|
```bash
|
|
git clone https://git.example.com/example-org/email-list-system.git /srv/email-list-system
|
|
```
|
|
|
|
4. At Git's prompts, enter the Gitea username and paste the token as the password.
|
|
|
|
Do not use a URL containing `username:token`, because shell history, process listings, and copied terminal output can expose it.
|
|
|
|
## Subsequent releases
|
|
|
|
From the checked-out repository, first inspect the revision and working tree, then pull the reviewed branch:
|
|
|
|
```bash
|
|
cd /srv/email-list-system
|
|
git status --short --branch
|
|
git pull --ff-only origin main
|
|
```
|
|
|
|
After a successful pull, update `EMAIL_LIST_GIT_COMMIT` in the VM's private `.env` to the exact checked-out revision before running `docker compose build`. Campaign approvals record this value, so it must match the reviewed code that is actually deployed.
|
|
|
|
`--ff-only` prevents Git from creating an unexpected merge commit on the VM. If the token is not cached or has expired, Git prompts for the same username and token again. Rotate or revoke the token in Gitea if the VM is decommissioned or the token may have been exposed.
|
|
|
|
## SSH deploy keys
|
|
|
|
An SSH deploy key can be used only when the Git server's SSH clone endpoint is reachable from the VM. If a proxy or access layer intercepts that route, use a scoped HTTPS token instead.
|