Skip to content

Commit 62a5108

Browse files
committed
fix railway sync script
1 parent d2ffef7 commit 62a5108

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

SPEC.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ Backend request validation, environment validation, and terminal upstream failur
195195

196196
### 8.3 Site Deploy
197197
- `AWS_S3_BUCKET`
198+
- `CLOUDFRONT_DISTRIBUTION_ID`
198199

199200
## 9. Validation
200201
The implementation is considered complete when:
@@ -214,7 +215,7 @@ The implementation is considered complete when:
214215
- The backend container image is built from `Backend/` using the checked-in `Backend/Dockerfile`.
215216
- The checked-in `Backend/railway.toml` codifies the Railway deploy settings that should live in source control, currently the Dockerfile builder and `/health` healthcheck.
216217
- The checked-in `Scripts/sync-github-actions-config.sh` script codifies how overlapping GitHub Actions repository variables and secrets can be synchronized from the local `.ENV` file.
217-
- The checked-in `Scripts/sync-railway-backend-variables.sh` script codifies how GitHub Actions synchronizes backend runtime variables into Railway before deployment.
218+
- The checked-in `Scripts/sync-railway-backend-variables.sh` script codifies how GitHub Actions synchronizes backend runtime variables into Railway before deployment, requiring `RAILWAY_PROJECT_ID` in the environment because `railway variable set` resolves project context from the environment rather than a `--project` flag.
218219
- The deployable product is the `Server` executable.
219220
- Railway builds and runs the production image from GitHub pushes, targeting the backend service with `railway up Backend --ci --path-as-root`.
220221
- The runtime base image remains `swift:6.2.4-bookworm-slim`.
@@ -228,7 +229,7 @@ The implementation is considered complete when:
228229
- The backend deploy job authenticates with a Railway project token, synchronizes the backend runtime variables into Railway, and deploys the `Backend/` directory directly to the configured Railway project, environment, and service.
229230
- Railway service-level GitHub autodeploy should be disabled when the GitHub Actions workflow is the active deployment path, to avoid duplicate backend deployments from the same push.
230231
- GitHub Actions repository variables and secrets are the source of truth for the backend runtime variables `GENERATED_IMAGES_BUCKET`, `OPENAI_API_KEY`, `OPENAI_IMAGE_MODEL`, `IMAGE_GEN_PREFIX`, `AWS_REGION`, `AWS_ACCESS_KEY_ID`, and `AWS_SECRET_ACCESS_KEY`.
231-
- The overlapping GitHub Actions repository variables and secrets can be seeded from the local `.ENV` file with `Scripts/sync-github-actions-config.sh`, but deployment-only values such as `RAILWAY_PROJECT_ID`, `RAILWAY_ENVIRONMENT_NAME`, `RAILWAY_SERVICE_NAME`, `RAILWAY_TOKEN`, and `BYTESIZED_CAFE_API_URL` remain manually managed because they do not belong in the local development env file.
232+
- The overlapping GitHub Actions repository variables and secrets can be seeded from the local `.ENV` file with `Scripts/sync-github-actions-config.sh`, but deployment-only values such as `RAILWAY_PROJECT_ID`, `RAILWAY_ENVIRONMENT_NAME`, `RAILWAY_SERVICE_NAME`, `RAILWAY_TOKEN`, `BYTESIZED_CAFE_API_URL`, and `CLOUDFRONT_DISTRIBUTION_ID` remain manually managed because they do not belong in the local development env file.
232233
- The backend deploy workflow sets `HOST=0.0.0.0` and `PORT=8080` in Railway by default, unless the deploy job overrides `RAILWAY_RUNTIME_HOST` or `RAILWAY_RUNTIME_PORT`.
233234
- Secret values are synchronized with Railway through `railway variable set KEY --stdin` so they are not exposed on the command line during GitHub Actions runs.
234235
- Inline shell in the deployment and validation workflows is minimized in favor of reusable repo-root `just` recipes so the same deployment task entry points can be reused locally and in CI.

Scripts/sync-github-actions-config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,5 @@ These deployment-only values still need to be managed separately because they ar
140140
- RAILWAY_SERVICE_NAME
141141
- RAILWAY_TOKEN
142142
- BYTESIZED_CAFE_API_URL
143+
- CLOUDFRONT_DISTRIBUTION_ID
143144
EOF

Scripts/sync-railway-backend-variables.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ required_environment_variables=(
1111
OPENAI_API_KEY
1212
OPENAI_IMAGE_MODEL
1313
RAILWAY_ENVIRONMENT_NAME
14+
RAILWAY_PROJECT_ID
1415
RAILWAY_SERVICE_NAME
1516
RAILWAY_TOKEN
1617
)
@@ -26,23 +27,23 @@ backendHost="${RAILWAY_RUNTIME_HOST:-0.0.0.0}"
2627
backendPort="${RAILWAY_RUNTIME_PORT:-8080}"
2728

2829
set_railway_variable() {
29-
npx -y @railway/cli variable set "$@" \
30+
npx -y @railway/cli variable set \
3031
--service "${RAILWAY_SERVICE_NAME}" \
3132
--environment "${RAILWAY_ENVIRONMENT_NAME}" \
3233
--skip-deploys \
33-
--yes
34+
"$@"
3435
}
3536

3637
set_railway_secret_from_stdin() {
3738
local variable_name="$1"
3839
local variable_value="$2"
3940

40-
printf '%s' "${variable_value}" | npx -y @railway/cli variable set "${variable_name}" \
41+
printf '%s' "${variable_value}" | npx -y @railway/cli variable set \
4142
--stdin \
4243
--service "${RAILWAY_SERVICE_NAME}" \
4344
--environment "${RAILWAY_ENVIRONMENT_NAME}" \
4445
--skip-deploys \
45-
--yes
46+
"${variable_name}"
4647
}
4748

4849
set_railway_variable \

0 commit comments

Comments
 (0)