From 8c46ef197250541d3e4962113f5e7ed041f2d961 Mon Sep 17 00:00:00 2001 From: danamir Date: Sun, 9 Aug 2026 01:04:13 +0300 Subject: [PATCH] Wire JWT_SECRET/POSTGRES_PASSWORD through Gitea Actions secrets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The job checks out into the runner's own workspace, not /opt/ruvdstests where DEPLOY.md has the human create a .env file — so docker compose here had no .env to read JWT_SECRET from and failed outright. POSTGRES_PASSWORD would have silently fallen back to the compose file's devpassword default instead of erroring, which on Deploy would have broken auth against the already-initialized pgdata volume. --- .gitea/workflows/ci-cd.yml | 11 +++++++++++ docs/CI-CD.md | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitea/workflows/ci-cd.yml b/.gitea/workflows/ci-cd.yml index 4337cfa..3c7fdc8 100644 --- a/.gitea/workflows/ci-cd.yml +++ b/.gitea/workflows/ci-cd.yml @@ -10,8 +10,19 @@ on: # checkout path — otherwise `docker compose` would derive the project name # from the checkout directory, potentially spinning up a second stack and # losing the `pgdata` volume instead of updating the running one. +# +# JWT_SECRET/POSTGRES_PASSWORD come from Gitea's own Actions secrets store +# rather than the `.env` file DEPLOY.md has the human create in +# `/opt/ruvdstests` — the job checks out into the runner's own workspace, not +# that directory, so there's no `.env` for `docker compose` to read here. +# Must match the values already in that `.env` file: on `Deploy` this +# `docker compose up -d` targets the same running project (via +# COMPOSE_PROJECT_NAME above), and a different POSTGRES_PASSWORD than what +# the live `pgdata` volume was initialized with breaks the DB connection. env: COMPOSE_PROJECT_NAME: ruvdstests + JWT_SECRET: ${{ secrets.JWT_SECRET }} + POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} jobs: build-test-deploy: diff --git a/docs/CI-CD.md b/docs/CI-CD.md index 94a5369..4a93d63 100644 --- a/docs/CI-CD.md +++ b/docs/CI-CD.md @@ -46,6 +46,16 @@ node in PATH` раньше, чем успевает выполниться чт Проверить, что раннер подключился: Site Administration → Actions → Runners — должен появиться `ruvdstest-prod` со статусом Idle/Online. +## Секреты + +Джоб чекаутит репозиторий во временную директорию раннера, а не в `/opt/ruvdstests` — своего +`.env` там нет, поэтому `JWT_SECRET`/`POSTGRES_PASSWORD` для `docker compose build`/`up` берутся не +из файла, а из хранилища секретов самой Gitea Actions: Settings репозитория → Actions → Secrets → +**Add Secret**. Завести `JWT_SECRET` и `POSTGRES_PASSWORD` со **значениями, совпадающими с тем, что +уже лежит в `/opt/ruvdstests/.env`** на сервере (`cat /opt/ruvdstests/.env` на сервере, скопировать +оттуда) — деплой-шаг пересоздаёт тот же самый запущенный проект (`COMPOSE_PROJECT_NAME` выше), и +рассинхронизация паролей с уже инициализированным `pgdata`-volume сломает подключение к БД. + ## Проверка Сделайте любой коммит и запушьте в `master` — во вкладке **Actions** репозитория должен появиться