Skip to content

Commit 30d6f67

Browse files
authored
chore(ci): reach the database over the tailnet when CI_DB_TAILNET is set (#9541)
1 parent 7ca3f1a commit 30d6f67

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ jobs:
114114
migrate:
115115
permissions:
116116
contents: read
117+
id-token: write
117118
name: migrate
118119
needs: [checks]
119120
# Explicit need results instead of the implicit success(): a skipped job
@@ -133,6 +134,8 @@ jobs:
133134
STAGING_DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
134135
MIGRATION_DATABASE_URL: ${{ secrets.MIGRATION_DATABASE_URL }}
135136
STAGING_MIGRATION_DATABASE_URL: ${{ secrets.STAGING_MIGRATION_DATABASE_URL }}
137+
TS_OAUTH_CLIENT_ID: ${{ secrets.TS_OAUTH_CLIENT_ID }}
138+
TS_AUDIENCE: ${{ secrets.TS_AUDIENCE }}
136139

137140
# Same ordering for dev (schema push before the dev image lands in ECR)
138141
migrate-dev:
@@ -146,6 +149,8 @@ jobs:
146149
environment: dev
147150
secrets:
148151
DEV_DATABASE_URL: ${{ secrets.DEV_DATABASE_URL }}
152+
TS_OAUTH_CLIENT_ID: ${{ secrets.TS_OAUTH_CLIENT_ID }}
153+
TS_AUDIENCE: ${{ secrets.TS_AUDIENCE }}
149154

150155
# Dev: build immutable images alongside the schema push and Trigger upload.
151156
image-dev:
@@ -1166,6 +1171,9 @@ jobs:
11661171
11671172
# Process docs embeddings (only when docs change, after images are promoted)
11681173
docs:
1174+
permissions:
1175+
contents: read
1176+
id-token: write
11691177
name: docs
11701178
needs: [promote, docs-changes]
11711179
# Explicit results: see migrate's comment.
@@ -1178,6 +1186,8 @@ jobs:
11781186
secrets:
11791187
DATABASE_URL: ${{ secrets.DATABASE_URL }}
11801188
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
1189+
TS_OAUTH_CLIENT_ID: ${{ secrets.TS_OAUTH_CLIENT_ID }}
1190+
TS_AUDIENCE: ${{ secrets.TS_AUDIENCE }}
11811191

11821192
# Create GitHub Release (only for version commits on main, after all builds complete)
11831193
release:

‎.github/workflows/docs.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
required: false
88
OPENAI_API_KEY:
99
required: false
10+
TS_OAUTH_CLIENT_ID:
11+
required: false
12+
TS_AUDIENCE:
13+
required: false
1014
workflow_dispatch:
1115
inputs:
1216
publish:
@@ -40,6 +44,10 @@ jobs:
4044
concurrency:
4145
group: docs-search-index-production
4246
cancel-in-progress: false
47+
permissions:
48+
contents: read
49+
# Tailscale workload identity federation exchanges this job's OIDC token.
50+
id-token: write
4351

4452
steps:
4553
- name: Record verified deployment and backup
@@ -68,6 +76,16 @@ jobs:
6876
provider: ${{ vars.CI_PROVIDER }}
6977
node-version: '24'
7078

79+
# Database IP restrictions admit the tailnet's app connector; see migrate.yml.
80+
- name: Join the tailnet
81+
if: vars.CI_DB_TAILNET == 'true'
82+
uses: tailscale/github-action@d1b6cd204f8dceda5b3eaad7f1f767be390056cd # v4.2.0
83+
with:
84+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
85+
audience: ${{ secrets.TS_AUDIENCE }}
86+
tags: tag:ci
87+
args: --accept-routes
88+
7189
- name: Process docs embeddings
7290
working-directory: ./apps/docs
7391
env:

‎.github/workflows/migrate.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
required: false
1919
STAGING_MIGRATION_DATABASE_URL:
2020
required: false
21+
TS_OAUTH_CLIENT_ID:
22+
required: false
23+
TS_AUDIENCE:
24+
required: false
2125
workflow_dispatch:
2226
inputs:
2327
environment:
@@ -46,6 +50,10 @@ jobs:
4650
concurrency:
4751
group: migrate-${{ inputs.environment }}
4852
cancel-in-progress: false
53+
permissions:
54+
contents: read
55+
# Tailscale workload identity federation exchanges this job's OIDC token.
56+
id-token: write
4957

5058
steps:
5159
# An environment only migrates from its own branch, so a manual dispatch
@@ -73,6 +81,18 @@ jobs:
7381
exit 1
7482
fi
7583
84+
# Database IP restrictions admit the tailnet's app connector, never a
85+
# runner's address. Linux nodes only use app connector routes with
86+
# --accept-routes.
87+
- name: Join the tailnet
88+
if: vars.CI_DB_TAILNET == 'true'
89+
uses: tailscale/github-action@d1b6cd204f8dceda5b3eaad7f1f767be390056cd # v4.2.0
90+
with:
91+
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
92+
audience: ${{ secrets.TS_AUDIENCE }}
93+
tags: tag:ci
94+
args: --accept-routes
95+
7696
- name: Checkout code
7797
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v6
7898
with:

0 commit comments

Comments
 (0)