Skip to content

Commit 09348aa

Browse files
tyler-daneclaude
andauthored
ci: migrate staging secrets to GitHub Environment (#1768)
* ci: migrate staging secrets to GitHub Environment Adds `environment: Staging` to the deploy job and removes all `STAGING_` prefixes from secrets and variables, relying on environment-level scoping instead of naming conventions. Also updates docs/CI-CD/workflows.md to document the split between repository-level secrets (DockerHub) and Staging environment secrets. Closes #1767 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * debug: add SSH auth diagnostics to staging deploy * debug: print derived public key for authorized_keys comparison * debug: remove SSH diagnostics * debug: capture supertokens container logs on deploy failure * debug: add mongo log capture on failure * debug: add backend log capture on failure * fix: chmod 644 compass.yaml so backend container can read it * debug: verify compass.yaml permissions and backend volume mount * debug: remove all diagnostic steps --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 97695f4 commit 09348aa

2 files changed

Lines changed: 41 additions & 20 deletions

File tree

.github/workflows/deploy-staging.yml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,27 @@ jobs:
2121
deploy:
2222
name: Deploy release to staging
2323
runs-on: ubuntu-latest
24+
environment: Staging
2425

2526
steps:
2627
- name: Deploy release to staging
2728
env:
2829
# Non-sensitive
29-
BACKEND_API_URL: ${{ vars.STAGING_BACKEND_API_URL }}
30-
FRONTEND_URL: ${{ vars.STAGING_FRONTEND_URL }}
31-
GOOGLE_CLIENT_ID: ${{ vars.STAGING_GOOGLE_CLIENT_ID }}
30+
BACKEND_API_URL: ${{ vars.BACKEND_API_URL }}
31+
FRONTEND_URL: ${{ vars.FRONTEND_URL }}
32+
GOOGLE_CLIENT_ID: ${{ vars.GOOGLE_CLIENT_ID }}
3233
RELEASE_TAG: ${{ inputs.tag }}
33-
SSH_USER: ${{ vars.STAGING_SSH_USER }}
34-
SSH_HOST: ${{ vars.STAGING_SSH_HOST }}
34+
SSH_USER: ${{ vars.SSH_USER }}
35+
SSH_HOST: ${{ vars.SSH_HOST }}
3536
# Sensitive
36-
COMPASS_SYNC_TOKEN: ${{ secrets.STAGING_COMPASS_SYNC_TOKEN }}
37-
GCAL_NOTIFICATION_TOKEN: ${{ secrets.STAGING_GCAL_NOTIFICATION_TOKEN }}
38-
GOOGLE_CLIENT_SECRET: ${{ secrets.STAGING_GOOGLE_CLIENT_SECRET }}
39-
MONGO_PASSWORD: ${{ secrets.STAGING_MONGO_PASSWORD }}
40-
MONGO_REPLICA_SET_KEY: ${{ secrets.STAGING_MONGO_REPLICA_SET_KEY }}
41-
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
42-
SUPERTOKENS_KEY: ${{ secrets.STAGING_SUPERTOKENS_KEY }}
43-
SUPERTOKENS_POSTGRES_PASSWORD: ${{ secrets.STAGING_SUPERTOKENS_POSTGRES_PASSWORD }}
37+
COMPASS_SYNC_TOKEN: ${{ secrets.COMPASS_SYNC_TOKEN }}
38+
GCAL_NOTIFICATION_TOKEN: ${{ secrets.GCAL_NOTIFICATION_TOKEN }}
39+
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
40+
MONGO_PASSWORD: ${{ secrets.MONGO_PASSWORD }}
41+
MONGO_REPLICA_SET_KEY: ${{ secrets.MONGO_REPLICA_SET_KEY }}
42+
SSH_KEY: ${{ secrets.SSH_KEY }}
43+
SUPERTOKENS_KEY: ${{ secrets.SUPERTOKENS_KEY }}
44+
SUPERTOKENS_POSTGRES_PASSWORD: ${{ secrets.SUPERTOKENS_POSTGRES_PASSWORD }}
4445
run: |
4546
# Strip 'v' prefix for Docker image tags (v0.5.18 -> 0.5.18)
4647
IMAGE_VERSION="${RELEASE_TAG#v}"
@@ -81,7 +82,7 @@ jobs:
8182
" clientSecret: \"${GOOGLE_CLIENT_SECRET}\"" \
8283
" notificationToken: \"${GCAL_NOTIFICATION_TOKEN}\"" \
8384
| ssh -i ~/.ssh/staging_key "$SSH_USER@$SSH_HOST" \
84-
"umask 077 && mkdir -p ~/compass && cat > ~/compass/compass.yaml"
85+
"umask 077 && mkdir -p ~/compass && cat > ~/compass/compass.yaml && chmod 644 ~/compass/compass.yaml"
8586
ssh -i ~/.ssh/staging_key "$SSH_USER@$SSH_HOST" "curl -fsSL https://raw.githubusercontent.com/SwitchbackTech/compass/${RELEASE_TAG}/self-host/compose.yaml -o ~/compass/compose.yaml"
8687
ssh -i ~/.ssh/staging_key "$SSH_USER@$SSH_HOST" "curl -fsSL https://raw.githubusercontent.com/SwitchbackTech/compass/${RELEASE_TAG}/self-host/compass -o ~/compass/compass && chmod +x ~/compass/compass"
8788
ssh -i ~/.ssh/staging_key "$SSH_USER@$SSH_HOST" "cd ~/compass && ./compass update"

docs/CI-CD/workflows.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,34 @@ show which release triggered or motivated the deploy.
8080
Manual staging redeploys do not rebuild images. Run `Deploy staging` with an
8181
existing tag after confirming the desired image tags already exist on Docker Hub.
8282

83-
### Required secrets
83+
### Required secrets and variables
8484

85-
All secrets go in **GitHub → Settings → Secrets and variables → Actions**:
85+
Secrets and variables are split between repository level (shared across workflows) and the `Staging` GitHub Environment (scoped to the deploy job).
8686

87-
| Secret | Value |
87+
**Repository-level** — GitHub → Settings → Secrets and variables → Actions:
88+
89+
| Name | Value |
8890
|---|---|
8991
| `DOCKERHUB_USERNAME` | Docker Hub username for the `switchbacktech` org |
9092
| `DOCKERHUB_TOKEN` | Docker Hub personal access token (Read & Write) |
91-
| `STAGING_SSH_HOST` | VPS IP address or hostname |
92-
| `STAGING_SSH_USER` | Linux user on the VPS that owns `~/compass` |
93-
| `STAGING_SSH_KEY` | Private key from the deploy keypair (the `compass-staging-deploy` file, not `.pub`) |
93+
94+
**`Staging` environment** — GitHub → Settings → Environments → Staging:
95+
96+
| Secret | Value |
97+
|---|---|
98+
| `SSH_KEY` | Private key from the deploy keypair |
99+
| `COMPASS_SYNC_TOKEN` | Token for compass sync |
100+
| `GCAL_NOTIFICATION_TOKEN` | Google Calendar notification token |
101+
| `GOOGLE_CLIENT_SECRET` | OAuth client secret |
102+
| `MONGO_PASSWORD` | MongoDB compass user password |
103+
| `MONGO_REPLICA_SET_KEY` | MongoDB replica set key |
104+
| `SUPERTOKENS_KEY` | SuperTokens API key |
105+
| `SUPERTOKENS_POSTGRES_PASSWORD` | SuperTokens PostgreSQL password |
106+
107+
| Variable | Value |
108+
|---|---|
109+
| `SSH_HOST` | VPS IP address or hostname |
110+
| `SSH_USER` | Linux user on the VPS that owns `~/compass` |
111+
| `BACKEND_API_URL` | Staging backend API URL |
112+
| `FRONTEND_URL` | Staging frontend URL |
113+
| `GOOGLE_CLIENT_ID` | OAuth client ID |

0 commit comments

Comments
 (0)