From 3a2a19b79b28de2f1527545a7524f9c21e3cf1de Mon Sep 17 00:00:00 2001 From: Bendik Aagaard Lynghaug Date: Thu, 6 Aug 2026 10:09:08 +0200 Subject: [PATCH] Add manually-triggered backfill workflow, no terminal/sudo needed Runs backfill_events using secrets.PORTAL_NATS_URL directly from the CI job's own env (same source deploy.yml's env-write step already uses) - avoids needing a sudo'd terminal session to read /etc/app/uhhm-portal.env's secrets off disk just to run a one-time migration tool. workflow_dispatch only, defaults to dry run. Co-Authored-By: Claude Sonnet 5 --- .gitea/workflows/backfill.yml | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .gitea/workflows/backfill.yml diff --git a/.gitea/workflows/backfill.yml b/.gitea/workflows/backfill.yml new file mode 100644 index 0000000..7c09217 --- /dev/null +++ b/.gitea/workflows/backfill.yml @@ -0,0 +1,44 @@ +name: Backfill events (one-time) + +# Manual only (workflow_dispatch, no push trigger) - this is a one-time +# migration, not something that should run on every deploy. Runs the +# same backfill_events binary (src/bin/backfill_events.rs) that would +# otherwise need a `sudo`'d terminal session on the host to read +# /etc/app/uhhm-portal.env's secrets - the CI job already has them +# natively via secrets.PORTAL_NATS_URL, same source deploy.yml's +# "Write service env" step uses, so nothing needs reading off disk at +# all. Defaults to a dry run; check "apply" to actually write. + +on: + workflow_dispatch: + inputs: + apply: + description: "Actually write (unchecked = dry run, writes nothing)" + type: boolean + default: false + +jobs: + backfill: + runs-on: bare + env: + CARGO_HOME: /var/local/cargo + RUSTUP_HOME: /var/local/rustup + PATH: /var/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin + SCCACHE_DIR: /var/local/sccache + SCCACHE_SERVER_PORT: "4228" + CARGO_TARGET_DIR: /var/local/cargo-target + NATS_URL: ${{ secrets.PORTAL_NATS_URL }} + steps: + - uses: actions/checkout@v4 + + - name: Build backfill_events + run: cargo build --release --features ssr --bin backfill_events + + - name: Run backfill + run: | + set -euo pipefail + if [ "${{ inputs.apply }}" = "true" ]; then + "$CARGO_TARGET_DIR/release/backfill_events" --apply + else + "$CARGO_TARGET_DIR/release/backfill_events" + fi